Getting your React Native App on an iOS device
As I was playing around with the awesome React Native library I encountered a few small hicups getting an app running on an actual device, so here’s how I made it work for me.
At the time of writing I’ve tested the following with:
- react-native 0.11.4
- nodejs v4.1.1
- XCode 7.0.1
I won’t go into much detail on how to get a React Native project going on your computer, as the nice guys at Facebook do an excellent job explaining this process.
After you’ve opened your initial project (generated by
react-native init <your-project>) in XCode you can run it on the simulator to verify it compiles and runs correctly.
Now, to get the app on your iPhone the documentation will want you to do the following:
- Change the IP in the URL from localhost to your laptop’s IP
This was not enough in my and my colleagues case. Additionally, you will want to do the following:
- Select the project in the navigator pane
- Go to the Build Settings tab
- Search for
Dead Code Strippingand set it to
Once that’s done you should be able to select your phone as build target and press “Build and run”.
Of course, when you want to make a final build which doesn’t require the device to be on the same WiFi as the computer you are serving the bundle.js file of off there’s more steps, but with the above we could get Live Reloading on an actual device to work.