setup-code-push.mo

Prerequisites (~2min)

What is CodePush

A React Native app is composed of JavaScript files and any accompanying images, which are bundled together by the packager and distributed as part of a platform-specific binary (i.e. an .ipa or .apk file). Once the app is released, updating either the JavaScript code (e.g. making bug fixes, adding new features) or image assets, requires you to recompile and redistribute the entire binary, which of course, includes any review time associated with the store(s) you are publishing to.

CodePush allows to rebuild and push only the modified JS code.

Pros:

  • Faster builds

  • Easier to update: no need to download the whole app again on HockeyApp

  • See deployment history and statistics

  • Easy rollbacks

  • If you enable it in production, you can install updates silently and automatically

Cons:

  • You rely on Microsoft Azure's servers

Here's an example, where we enabled it on staging in order to speed up development (at the bottom of the screen). Code Push

Steps

1. Install the AppCenter cli (~1 min)

circle-check

2. Login into AppCenter (~4 min)

Login with your GitHub or Google account:

circle-check

3. Configure CodePush on AppCenter's servers (~5 min)

circle-check

4. Install the react-native module (~5 min)

Find out the adequate version of react-native-code-push using the supported-react-native-platforms sectionarrow-up-right in the react-native-code-push documentation.

react-native link command adds a pod in your Podfile.

  • If you don't already have React in your Podfile, it is recommended to remove the added line, commit, and follow the Microsoft tutorial herearrow-up-right, paragraph Plugin Installation (iOS - Manual).

  • If you already have React in your Podfile, make sure to bundle exec pod install in order to update Podfile.lock

circle-check

5. Update your code (~35 min)

Update App.js (~10 min)

circle-check

Add CodePushUpdateButton.js (~5 min)

You can put the update process on any page you like, or even check if an update is available with a long press somewhere... It is up to you and your PO.

Add this CodePushUpdateButton somewhere in your app.

circle-check

Create bin/deploy.sh (~10 min)

circle-check

6. Test! (~15 min)

Open your PR, merge into the main branch. Have a hard build. You can now deploy with code-push.

Bump your versions into .env.staging file before every hard deploy. If not, your JS code might try to call native libraries not present in your app.

7. Externalize the keys (optional) (~10min)

Externalize the keys in Info.plist and AndroidManifest.xml: see https://github.com/kraynel/code-push-demo/commit/3cdd2496fab763a9814c1898c73505cd14fca9d1arrow-up-right

Troubleshooting

You can try the CodePush documentationarrow-up-right, and particularly the react-native sectionarrow-up-right.

You should also Andon the teams with a working CodePush process:

Last updated