Video: Building for Production

Level 2 React Native

21 videos

Released: null

User avatar

Instructor

Spencer Carli
AutoPlay

Building for Production

iOS

First, ensure you've set up an Apple developer account.

To test a production version of your application, in Xcode, go to Product → Scheme → Edit Scheme. Select the "Run" tab and change the "Build Configuration" to "Release". Build the app as you would normally to test the app in production mode. Note: Make sure to switch this back to re-enable live reloading/development tools.

To build for production, in Xcode, select Product → Build and follow the prompts Xcode gives you to upload it to App Store Connect.

Full iOS Docs: https://facebook.github.io/react-native/docs/running-on-device#building-your-app-for-production

Android

First, ensure you've set up a Google Play Developer Account.

Next, you need to sign your application. The key you're about to create is the key to your app once it's published. If you lose this key or forget any of the associated passwords you will not be able to update your app!

To generate they key fun the following command.

Note: You can change my-release-key.keystore and my-key-alias to whatever you want, just make sure to not the name.

TODO

Place the resulting .keystore file in the android/app directory of your project.

Next edit either ~/.gradle/gradle.properties or android/gradle.properties (note that these files are outside of your project at the root of your machine) and add the following.

TODO

Change MY_APP to something related to the app you're working on (such as the project name). The values should align with those you set when creating the keystore file.

Next, you need to configure the android app to use those values when signing the application with your keystore file. In android/app/build.gradle add the following:

TODO

Make sure to use the variable names that align with what you set previously.

Finally, you can generate the release build:

TODO

The final, signed, production build will then exist at android/app/build/outputs/apk/release/app-release.apk. To test it first uninstall the existing app from your target device and then run react-native run-android --variant=release.

To publish the app you'll upload the app-release.apk to the Google Play console.

Full Android Docs: https://facebook.github.io/react-native/docs/signed-apk-android