Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for iOS static bundle #16551

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion docs/RunningOnDevice.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,34 @@ To configure your app to be built using the `Release` scheme, go to **Product**

![](img/ConfigureReleaseScheme.png)

### 3. Build app for release
### 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. To do this requires a code change in your App 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"];
```

This will now reference the `main.jsbundle` resource file that is created during the `Bundle React Native code and images` Build Phase in Xcode.

> Note: The static bundle is built every time you target a physical device, even in Debug. If you want to save time, turn off bundle generation in Debug by adding theollowing to your shell script in Xcode Build Phase `Bundle React Native code and images`:
```
if [ "${CONFIGURATION}" == "Debug" ]; then
export SKIP_BUNDLING=true
fi
```

#### Pro Tip
As your App Bundle grows in size, you may start to see a White Screen flash between your Splash Screen and the display of your root Application view. If this is thease, you can add the following code to `AppDelegate.m` in order to keep your Splash Screen displayed during the transition.
```
// Place this code after "[self.window makeKeyAndVisible]" and before "return YES;"
UIView* launchScreenView = [[[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil] objectAtIndex:0];
launchScreenView.frame = self.window.bounds;
rootView.loadingView = launchScreenView;
```

### 4. Build app for release

You can now build your app for release by tapping `⌘B` or selecting **Product** → **Build** from the menu bar. Once built for release, you'll be able to distribute the app to beta testers and submit the app to the App Store.

Expand Down