The first version of our application is complete, which means that we are ready to go through the process of creating the production builds. In this chapter, we will start by showing you how to generate and run the application off of a static JavaScript bundle. Then, in preparation for the App Store, we will use Xcode to build our iOS release. Lastly, for Android we will walk through the set of command-line tools and scripts provided by React Native to build the final APK.
In this chapter, we will cover the following:
static bundle
in place of react-native start
So far, we have been serving the application's static bundle (where all of our JavaScript code lives) from a node server started by either Xcode or a terminal using react-native start
. Before we create releases for iOS and Android, we need to generate the static JS bundle that our application will load. We will begin by creating the release in iOS; for Android, skip to the generating the Android APK
section.
Once again, we are going to use the react-native-cli
and execute the bundle
command. The bundle
command requires three flags: c
, platform
, and bundle-output
. The entry-file
specifies the path to the root component, the platform is either iOS or Android, and bundle-output
is the path to place the generated bundle.
From the terminal in the root directory, run react-native bundle
with an entry-file
of index.ios.js
, platform iOS
, and point the path of the bundle-output
to ios/main.jsbundle
:
$ react-native bundle --entry-file index.ios.js --platform ios --bundle-output ios/main.jsbundle bundle: Created ReactPackager bundle: Closing client bundle: start bundle: finish bundle: Writing bundle output to: ios/main.jsbundle bundle: Done writing bundle output
Assets destination folder is not set, skipping...
More details about react-native bundle
for iOS can be found in the React Native documentation at https://facebook.github.io/react-native/docs/running-on-device-ios.html#using-offline-bundle.
18.117.103.219