This is a demo repo implementing CodePush for Expo dev client using react-native-code-push-plugin config plugin.
:information_source: Note
This will not work on Expo Go projects, it will only work for Expo Development Client projects.
npm install
--local
to this commands, more here Setting up the development environment):
npx eas build --profile development --platform android --clear-cache
npx eas build --profile development --platform ios --clear-cache
npx eas build --profile production --platform android --clear-cache
npx eas build --profile production --platform ios --clear-cache
npx eas build --profile production-android-apk --platform android --clear-cache
After you have your app running on your device, try to change something in code (ie: edit setTimesPressed
function) and then upload a CodePush release (see Create deployments), wait a minute and then restart the app or set it to background and then foreground it again.
At this point you should be able to tweak the project, analyze it and set it up in your production project, maybe implementing manual CodePush updates.
At this point, CodePush seems to dislike local imports that use @/ instead of the good old ./. For this to work, you need to change all @/ imports with ./ paths. If you know how to fix this, please tell or send a PR. Issue reported here
To enable the plugin in your project, you need to install it with npm install -s react-native-code-push-plugin
and set the plugin config in your app.json, app.config.json or app.config.js. If you don't need Android or iOS CodePush support simply remove the Android or iOS section.
"plugins": [
[
"react-native-code-push-plugin",
{
"android": {
"CodePushDeploymentKey": ""
},
"ios": {
"CodePushDeploymentKey": ""
}
}
]
]
Currently, there's an open PR to have this plugin out of the box in react-native-code-push package but still waiting for approval to merge, if you can, write a comment asking for this plugin to be added to the package. Here's the PR link Expo plugin to simplify installation with expo
Releasing CodePush updates using the App Center CLI
npm install -g appcenter-cli
appcenter login
Adjust --display-name --release-type params as you need
appcenter apps create --platform React-Native --os Android --display-name "android-expo-code-push-plugin-managed-workflow" --release-type Development
appcenter apps create --platform React-Native --os iOS --display-name "ios-expo-code-push-plugin-managed-workflow" --release-type Development
appcenter apps list
Here you get the deployment key. Adjust -a and Development params as you need
appcenter codepush release-react -a YOURACCOUNT/android-expo-code-push-plugin-managed-workflow --deployment-name 'Development' --entry-file 'node_modules/expo/AppEntry.js' --use-hermes --target-binary-version '1.0.1'
appcenter codepush release-react -a YOURACCOUNT/ios-expo-code-push-plugin-managed-workflow --deployment-name 'Development' --entry-file 'node_modules/expo/AppEntry.js' --use-hermes --target-binary-version '1.0.1'
Adjust -a param as you need
appcenter codepush deployment list -a YOURACCOUNT/android-expo-code-push-plugin-managed-workflow --displayKeys
appcenter codepush deployment list -a YOURACCOUNT/ios-expo-code-push-plugin-managed-workflow --displayKeys
Adjust -a, --deployment-name, --entry-file should be pointed at your file stated in main in package.json. In this repo is "main": "App.tsx"
, --use-hermes and --target-binary-version params as you need. See CodePush docs here for more info
appcenter codepush release-react -a YOURACCOUNT/android-expo-code-push-plugin-managed-workflow --deployment-name "Development" --entry-file App.tsx --use-hermes --target-binary-version "1.0.0"
appcenter codepush release-react -a YOURACCOUNT/ios-expo-code-push-plugin-managed-workflow --deployment-name "Development" --entry-file App.tsx --use-hermes --target-binary-version "1.0.0"