When testing my Android app I had the option to load between development & production bundles.
Does anyone know if you can do they same for IOS? I've changed the build scheme in Xcode to release but it's still loading the development bundle.
Anyone know how to do this?
For loading the correct file you actually need to edit the AppDelegate.M file in Xcode. The code which is down here will check if the build settings are debug (so it loads the network file) or release (load the local bundle)
#ifdef DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
Before you can set the jsCodeLocation you need to generate the correct file. You can do this with the following command:
node node_modules/react-native/local-cli/cli.js bundle --entry-file='index.ios.js' --bundle-output='./ios/YourApp/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'
This will put the main.jsbundle in the ios folder (which is in the root of your react native project I assume)
After you've done the steps above you can build and deploy your app and try it out :)
Mark
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.