From 6be0f8e8dafdda668697c8955b8d5acee0943755 Mon Sep 17 00:00:00 2001
From: Website Deployment Script
During the development process, React Native has loaded your JavaScript code dynamically at runtime. For a production build, you want to pre-package the JavaScript bundle and distribute it inside your application. Doing this requires a code change in your code so that it knows to load the static bundle.
-In AppDelegate.m, change the default jsCodeLocation to point to the static bundle that is built in Release.
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
+In AppDelegate.m, change jsCodeLocation to point to the static bundle if you're not in debug mode.
+#ifdef DEBUG
+ jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
+#else
+ jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
+#endif
This will now reference the main.jsbundle resource file that is created during the Bundle React Native code and images Build Phase in Xcode.
diff --git a/docs/next/running-on-device/index.html b/docs/next/running-on-device/index.html
index 3a6d7714763..e7b537f05ce 100644
--- a/docs/next/running-on-device/index.html
+++ b/docs/next/running-on-device/index.html
@@ -275,8 +275,12 @@ emulator-5554 offline
3. Configure app to use static bundle
During the development process, React Native has loaded your JavaScript code dynamically at runtime. For a production build, you want to pre-package the JavaScript bundle and distribute it inside your application. Doing this requires a code change in your code so that it knows to load the static bundle.
-In AppDelegate.m, change the default jsCodeLocation to point to the static bundle that is built in Release.
- jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
+In AppDelegate.m, change jsCodeLocation to point to the static bundle if you're not in debug mode.
+#ifdef DEBUG
+ jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
+#else
+ jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
+#endif
This will now reference the main.jsbundle resource file that is created during the Bundle React Native code and images Build Phase in Xcode.