简体   繁体   English

React Native 应用程序未在 XCode iOS 模拟器中运行

[英]React Native app not running in XCode iOS simulator

I try to make my first steps using React Native.我尝试使用 React Native 迈出第一步。 Development for Android (on Windows host) works. Android 开发(在 Windows 主机上)有效。 Now I wanted to test iOS, and tried to set up a development environment on a MacBook Pro.现在我想测试iOS,并尝试在MacBook Pro上设置开发环境。

Problem: React Native starts the iOS simulator, and then nothing happens any more.问题:React Native 启动了 iOS 模拟器,然后就没有任何反应了。 The simulator runs OK, but my React native app won't start.模拟器运行正常,但我的 React 本机应用程序无法启动。

What do I need to do to get my React Native installation going?我需要做什么才能让我的 React Native 安装运行?

More Info:更多信息:

I set up XCode and React Native according to the docs on the MacBook Pro running OSx 10.13.2 (High Sierra).我根据运行 OSx 10.13.2 (High Sierra) 的 MacBook Pro 上的文档设置了 XCode 和 React Native。 XCode was installed and tested successfully, including the simulator. XCode 安装并测试成功,包括模拟器。

When I installed Node.js I deliberately picked an older version (containing npm 4.2.0), since forums say that React Native does still have problems with npm 5. I also installed Homebrew and Watchman, like stated in the docs.当我安装 Node.js 时,我特意选择了一个旧版本(包含 npm 4.2.0),因为论坛说 React Native 仍然有 npm 5 的问题。我还安装了 Homebrew 和 Watchman,如文档中所述。

To initialize an empty project, I used要初始化一个空项目,我使用

create-react-native-app HelloWorldProject

and a projet structure got created in my Documents folder.并且在我的 Documents 文件夹中创建了一个项目结构。

If I finally fire up my "Hello World" test app using如果我最终使用以下命令启动我的“Hello World”测试应用程序

cd HelloWorldProject
sudo react-native run-ios

the system responds:系统响应:

Starting packager ...
Starting simulator ...

and then nothing happens.然后什么也没有发生。 The simulator does indeed start (boot --> apple logo --> progress bar --> IOs start screen), but nothing happens afterwards.模拟器确实启动了(启动 --> 苹果标志 --> 进度条 --> IO 启动屏幕),但之后没有任何反应。

Edit I have given up on React Native for several reasons, I leave this question here for documentary purposes, but I cannot verify or accept any answer, I don't have a React Native development environment any more.编辑我已经放弃 React Native 有几个原因,我把这个问题留在这里是为了记录,但我无法验证或接受任何答案,我不再有 React Native 开发环境了。

It's probably because you used sudo .这可能是因为您使用了sudo /.expo/ is owned by root. /.expo/归 root 所有。 Try to change the ownership with尝试更改所有权

sudo chown -R `whoami` ~/.expo

Refer https://github.com/react-community/create-react-native-app/issues/422参考https://github.com/react-community/create-react-native-app/issues/422

Even everything in your app seems fine, sometime you face the issue that the app is taking too much time to load either through terminal or Xcode.即使您的应用程序中的所有内容看起来都很好,但有时您会遇到应用程序通过终端或 Xcode 加载时间过长的问题。 If there is no any other specific issue with your project, the following solution works most of the time:如果您的项目没有任何其他特定问题,则以下解决方案大部分时间都有效:

  1. Go to your app folder and then go to 'iOS' folder.转到您的应用程序文件夹,然后转到“iOS”文件夹。

  2. Delete 'Podfile.lock' and 'Pods' folder.删除“Podfile.lock”和“Pods”文件夹。

  3. Execute the following command in Terminal from your 'ios' folder, that will bring back the 'Podfile.lock' and required Pods will be installed to 'Pods' folder:在终端中从您的“ios”文件夹中执行以下命令,这将带回“Podfile.lock”并且所需的 Pod 将安装到“Pods”文件夹中:

    pod install吊舱安装

  4. Delete the 'build' folder in your 'iOS' folder.删除“iOS”文件夹中的“build”文件夹。

  5. Run the following command in terminal:在终端中运行以下命令:

    react-native run-ios react-native run-ios

  6. While the terminal is running, open '.xcworkspace' in your 'ios' folder in Xcode.在终端运行时,在 Xcode 的“ios”文件夹中打开“.xcworkspace”。

The above steps will make sure it will be build your react native project newly and will run on the simulator.上述步骤将确保它将新构建您的 React Native 项目并在模拟器上运行。

Thanks谢谢

Wasantha Wijayaratna瓦桑塔·维贾亚拉特纳

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native-在iOS模拟器中撤消已删除的应用 - React Native - Undo the deleted app in iOS simulator 无法在 iOS 模拟器上的 React Native 中运行应用程序 - Cant run app in React native on iOS simulator Ios 模拟器未启动 React Native 应用程序 - Ios Simulator not launching react native app 未在iOS模拟器中安装React Native App - React Native App is not installing in ios simulator React-Native/XCode 12.4/iOS 模拟器 - 应用启动时出现黑屏 - React-Native/XCode 12.4/iOS Simulator - Black Screen on App Start-Up React Native:使用 Xcode 与`react-native run-ios` 运行应用程序有什么区别? - React Native: What is the difference between running app with Xcode vs `react-native run-ios`? 在 iOS 模拟器中运行 React Native 应用程序时找不到 UMModuleRegistryAdapter.h - UMModuleRegistryAdapter.h not found when running React Native app in iOS simulator React Native(来自 xcode)不在 iPhone 上运行,但在模拟器上运行 - React native (from xcode) not running on iPhone but working on a simulator React Native 应用程序样式不在 xcode 模拟器上呈现,但在 Android Studio 上工作? - React Native app style not rendering on xcode simulator but working on Android Studio? React Native - Xcode Simulator 上的 .app 文件要求提供 Bundle URL - React Native - .app file on Xcode Simulator asking for Bundle URL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM