【问题标题】:React-native screen does not appear on the iOS simulator using react-native使用 react-native 的 iOS 模拟器上不会出现 React-native 屏幕
【发布时间】:2020-10-10 07:33:58
【问题描述】:

我现在正在尝试使用 react-native 开发一个应用程序,但是第一个项目效果不佳。

环境

  • cocoapods-1.9.3
  • 节点 v10.16.2
  • 守望者 4.9.0
  • Apple Swift 版本 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53) 目标:x86_64-apple-darwin19.4.0

我尝试过的

我按照official cite做了环境设置。

$ npx react-native init AwesomeProject
$ cd AwesomeProject
$ npx react-native run-ios

而且我看到了 iOS 屏幕,但是没有像“Welcome to react-native”这样的语句,应该出现在屏幕上。 我在模拟器上看到的是this

当我执行命令时

$ npx react-native start

我可以看到这样的 react-native logo,

               ######                ######               
             ###     ####        ####     ###             
            ##          ###    ###          ##            
            ##             ####             ##            
            ##             ####             ##            
            ##           ##    ##           ##            
            ##         ###      ###         ##            
             ##  ########################  ##             
          ######    ###            ###    ######          
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######          
             ##  ########################  ##             
            ##         ###      ###         ##            
            ##           ##    ##           ##            
            ##             ####             ##            
            ##             ####             ##            
            ##          ###    ###          ##            
             ###     ####        ####     ###             
               ######                ######               

                 Welcome to React Native!
                Learn once, write anywhere



To reload the app press "r"
To open developer menu press "d"

但是下面有一个警告声明。

warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.
info Reloading app...

如何获得类似this picture 的模拟器屏幕,显示为成功结果?

【问题讨论】:

  • 你解决了吗?每个启动命令都需要在自己的终端中运行。 ios-start 可能需要大约 10 分钟才能构建,然后您才能看到反应屏幕。

标签: android ios swift reactjs react-native


【解决方案1】:

在你的 React Native 项目文件夹中运行 npx react-native start: 然后运行npx react-native run-ios。等待 Metro bundler 启动,然后运行此命令

另一种方法是从文档中尝试 expo 版本解决方案或仔细阅读 React Native CLI 快速入门解决方案。

【讨论】:

    猜你喜欢
    • 2021-11-26
    • 2022-07-26
    • 2021-06-22
    • 1970-01-01
    • 1970-01-01
    • 2017-10-18
    • 2022-07-07
    • 2019-06-27
    • 2019-08-07
    相关资源
    最近更新 更多