Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run my react-native app on the device outside of my home network?

Right now I can successfully run my react-native app on the device (iPhone/iOS). However, I have to be connected to my WI-FI for that to work (no need to be plugged in with USB). When I disconnect from my WI-FI the app no longer works on the phone. It doesn't load properly/crashes. Is there a way to run my react-native app on the device outside of my home network/wi-fi?

like image 648
Stephani Bishop Avatar asked Aug 11 '16 07:08

Stephani Bishop


1 Answers

If you are running react-native 0.29.0 or above you can simply change the scheme to "release" and it should build an offline bundle of your app - so you can use it without being on your wifi.

If you are using react-native 0.28.0 or below then you still need to change the scheme to "release", but you also need to change some code in your AppDelegate.m file:

Comment out this line:

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

And then uncomment this line:

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

This puts your app into "Production" mode so you will not be able to access the debug menu.

Hope this helps! :)

like image 130
David Avatar answered Sep 18 '22 20:09

David