Getting your React Native App on an iOS device

Posted October 8th, 2015 • 2 min read

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:

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:

  1. Open AwesomeApp/ios/AwesomeApp/AppDelegate.m
  2. 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:

  1. Select the project in the navigator pane
  2. Go to the Build Settings tab
  3. Search for Dead Code Stripping and set it to NO

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.

Happy Coding.

Stay up to date

Want to know when a new post comes out and stay in the loop on tips, tricks and gotchas? Consider signing up for the Mindthecode newsletter.

Comments

Keep reading

May 16th, 2012 • 3 min read
With this little gem you can watch specific folders or file extensions and run commands based on the files you watch.
April 14th, 2011 • 3 min read
I heard a lot about SASS, mostly a lot of people raving about how it was the best thing since chocolate.
February 28th, 2013 • 5 min read
In this post I want to show you how you can customize the terminal to not only make it look cool but work better, too