简体   繁体   中英

React Native app not running in XCode iOS simulator

I try to make my first steps using React Native. Development for Android (on Windows host) works. Now I wanted to test iOS, and tried to set up a development environment on a MacBook Pro.

Problem: React Native starts the iOS simulator, and then nothing happens any more. The simulator runs OK, but my React native app won't start.

What do I need to do to get my React Native installation going?

More Info:

I set up XCode and React Native according to the docs on the MacBook Pro running OSx 10.13.2 (High Sierra). XCode was installed and tested successfully, including the simulator.

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.

To initialize an empty project, I used

create-react-native-app HelloWorldProject

and a projet structure got created in my Documents folder.

If I finally fire up my "Hello World" test app using

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.

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.

It's probably because you used sudo . /.expo/ is owned by root. Try to change the ownership with

sudo chown -R `whoami` ~/.expo

Refer 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. 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.

  2. Delete 'Podfile.lock' and 'Pods' folder.

  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:

    pod install

  4. Delete the 'build' folder in your 'iOS' folder.

  5. Run the following command in terminal:

    react-native run-ios

  6. While the terminal is running, open '.xcworkspace' in your 'ios' folder in Xcode.

The above steps will make sure it will be build your react native project newly and will run on the simulator.

Thanks

Wasantha Wijayaratna

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM