setup-code-push.mo
Owner: Louis Lagrange
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
Steps
1. Install the AppCenter cli (~1 min)
CHECK
appcenter -v
should give you a version.
2. Login into AppCenter (~4 min)
Login with your GitHub or Google account:
CHECK
You should see your profile info with appcenter profile list
.
3. Configure CodePush on AppCenter's servers (~5 min)
CHECK
Check: you have written down the deployment keys in a temporary file.
4. Install the react-native module (~5 min)
Find out the adequate version of react-native-code-push using the supported-react-native-platforms section 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 yourPodfile
, it is recommended to remove the added line, commit, and follow the Microsoft tutorial here, paragraph Plugin Installation (iOS - Manual).If you already have
React
in yourPodfile
, make sure tobundle exec pod install
in order to updatePodfile.lock
CHECK
Check: your app builds on both Android and iOS, in debug and release mode.
5. Update your code (~35 min)
Update App.js (~10 min)
CHECK
Check: Manually set "ENV" to staging
and check the logs on iOS and Android. You shouldn't see any warning for CodePush.
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.
CHECK
On the simulator, you should see an update button if you force the env to staging.
Create bin/deploy.sh (~10 min)
CHECK
yarn deploy -- -t hard
should deploy your application with Fastlane. yarn deploy
should deploy with CodePush.
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/3cdd2496fab763a9814c1898c73505cd14fca9d1
Troubleshooting
You can try the CodePush documentation, and particularly the react-native section.
You should also Andon the teams with a working CodePush process:
Last updated