A Comprehensive Guide to CodePush in Microsoft App Center

Sahil Pandya
3 min readJul 30, 2023

--

Introduction:
CodePush is a powerful platform offered by Microsoft App Center that allows developers to deploy runtime JS bundles in release or UAT builds without having to go through the App Store or Play Store release process. This blog will explore the concept of CodePush, its benefits, installation process, and essential commands used in its implementation.

What is CodePush?
CodePush, integrated with Microsoft App Center, is a service that facilitates the seamless deployment of runtime JavaScript bundles to your mobile app’s users. With CodePush, developers can push out updates instantly, addressing critical bugs or issues in the production environment without waiting for a standard app release cycle.

Why Use CodePush?
1. Swift Bug Fixes: In cases where bugs or glitches are discovered in the production version of the app, CodePush enables developers to rapidly fix and update the affected code without waiting for a full app release.

2. Minimized Impact: By addressing issues quickly with CodePush, developers can prevent major user disruptions and reduce the likelihood of escalation charges due to prolonged problems.

How to Install CodePush?
The installation of CodePush is straightforward and can be done by following the steps outlined in the official setup guide, which can be found at: https://learn.microsoft.com/en-us/appcenter/sdk/getting-started/

Essential CodePush Commands:
To effectively use CodePush, developers should familiarize themselves with the following essential commands:

1. `code-push login`: This command allows developers to log in to their CodePush account within the terminal or command prompt.

2. `code-push -h`: This command provides access to the help menu, where developers can find information about different CodePush commands and their usage.

3. `code-push app list`: This command displays a list of the apps registered with CodePush.

4. `code-push release-react appCenterFolderPath ios`: Used to release the CodePush update to the designated app and platform.

5. `code-push promote appCenterFolderPath Staging Production`: This command promotes a CodePush release from the Staging environment to Production.

6. `code-push debug ios`: This command enables debugging of CodePush updates for iOS.

7. `code-push rollback appCenterFolderPath Staging`: Developers can use this command to rollback to a previous CodePush release in the Staging environment.

8. `code-push rollback appCenterFolderPath Staging -targetRelease versionNumber`: This command allows specifying a target version number for the rollback operation.

9. `code-push release-react appCenterFolderPath ios -deploymentName Production`: Used to release CodePush updates specifically for the Production deployment.

Local Testing with CodePush:
For local testing purposes, developers can make changes inside the `node_modules/react-native-xcode.sh` file and modify conditions in `appdelegate.m`. These modifications are especially useful when testing in the simulator.

// Inside node_modules/react-native-xcode.sh
# remove the "exit" command
# ...

// Inside appdelegate.m
#ifdef DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#else
jsCodeLocation = [CodePush bundleURL];
#endif

By removing the “exit” command in node_modules/react-native-xcode.sh and adjusting the conditions in appdelegate.m, you can test the CodePush updates in the simulator.

Reference Links:
For further information and multi-deployment testing with CodePush, refer to the official GitHub repository: https://github.com/Microsoft/react-native-code-push#multi-deployment-testing

Where to Check Your Released Builds Using CodePush:
To access and manage CodePush releases for your app, log in to https://appcenter.ms/login, navigate to your app, select “Distribute” from the left menu, and choose the CodePush option. There, you will find a comprehensive list of CodePush releases for various environments.

Conclusion:
CodePush in Microsoft App Center is a valuable tool for developers, offering a convenient and efficient way to push updates to production or UAT builds without undergoing the lengthy App Store or Play Store release process. By leveraging CodePush, developers can swiftly address issues, minimize user disruptions, and enhance the overall user experience. To get started, follow the installation guide and explore the plethora of CodePush commands available for seamless mobile app deployment.

--

--

Sahil Pandya
Sahil Pandya

Written by Sahil Pandya

Learning, Exploring, Implementing and then Writing things after experience.

No responses yet