Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 6872c12

Browse files
reduce readme.md size (#1038)
reduce readme.md size * move android and ios parts of the multi-deployment testing chapter into the separate files * improve navigation tree
1 parent 7735db2 commit 6872c12

File tree

3 files changed

+150
-146
lines changed

3 files changed

+150
-146
lines changed

README.md

Lines changed: 5 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This plugin provides client-side integration for the [CodePush service](http://c
1919
* [Store Guideline Compliance](#store-guideline-compliance)
2020
* [Releasing Updates](#releasing-updates)
2121
* [Multi-Deployment Testing](#multi-deployment-testing)
22+
* [Android](docs/multi-deployment-testing-android.md)
23+
* [iOS](docs/multi-deployment-testing-ios.md)
2224
* [Dynamic Deployment Assignment](#dynamic-deployment-assignment)
2325
* [API Reference](#api-reference)
2426
* [JavaScript API](docs/api-js.md)
@@ -258,154 +260,11 @@ Taking advantage of the `Staging` and `Production` deployments allows you to ach
258260

259261
*NOTE: If you want to get really fancy, you can even choose to perform a "staged rollout" as part of #3, which allows you to mitigate additional potential risk with the update (e.g. did your testing in #2 touch all possible devices/conditions?) by only making the production update available to a percentage of your users (e.g. `code-push promote <APP_NAME> Staging Production -r 20%`). Then, after waiting for a reasonable amount of time to see if any crash reports or customer feedback comes in, you can expand it to your entire audience by running `code-push patch <APP_NAME> Production -r 100%`.*
260262

261-
You'll notice that the above steps refer to a "staging build" and "production build" of your app. If your build process already generates distinct binaries per "environment", then you don't need to read any further, since swapping out CodePush deployment keys is just like handling environment-specific config for any other service your app uses (e.g. Facebook). However, if you're looking for examples on how to setup your build process to accommodate this, then refer to the following sections, depending on the platform(s) your app is targeting.
263+
You'll notice that the above steps refer to a "staging build" and "production build" of your app. If your build process already generates distinct binaries per "environment", then you don't need to read any further, since swapping out CodePush deployment keys is just like handling environment-specific config for any other service your app uses (e.g. Facebook). However, if you're looking for examples on how to setup your build process to accommodate this, then refer to the following sections, depending on the platform(s) your app is targeting:
262264
263-
### Android
265+
* [Android](docs/multi-deployment-testing-android.md)
266+
* [iOS](docs/multi-deployment-testing-ios.md)
264267
265-
The [Android Gradle plugin](http://google.github.io/android-gradle-dsl/current/index.html) allows you to define custom config settings for each "build type" (e.g. debug, release), which in turn are generated as properties on the `BuildConfig` class that you can reference from your Java code. This mechanism allows you to easily configure your debug builds to use your CodePush staging deployment key and your release builds to use your CodePush production deployment key.
266-
267-
To set this up, perform the following steps:
268-
269-
1. Open your app's `build.gradle` file (e.g. `android/app/build.gradle` in standard React Native projects)
270-
271-
2. Find the `android { buildTypes {} }` section and define `buildConfigField` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively. If you prefer, you can define the key literals in your `gradle.properties` file, and then reference them here. Either way will work, and it's just a matter of personal preference.
272-
273-
```groovy
274-
android {
275-
...
276-
buildTypes {
277-
debug {
278-
...
279-
// Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
280-
buildConfigField "String", "CODEPUSH_KEY", '""'
281-
...
282-
}
283-
284-
releaseStaging {
285-
...
286-
buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_STAGING_KEY>"'
287-
...
288-
}
289-
290-
release {
291-
...
292-
buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_PRODUCTION_KEY>"'
293-
...
294-
}
295-
}
296-
...
297-
}
298-
```
299-
300-
*NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
301-
302-
*NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
303-
304-
4. Pass the deployment key to the `CodePush` constructor via the build config you just defined, as opposed to a string literal.
305-
306-
**For React Native >= v0.29**
307-
308-
Open up your `MainApplication.java` file and make the following changes:
309-
310-
```java
311-
@Override
312-
protected List<ReactPackage> getPackages() {
313-
return Arrays.<ReactPackage>asList(
314-
...
315-
new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
316-
...
317-
);
318-
}
319-
```
320-
321-
**For React Native v0.19 - v0.28**
322-
323-
Open up your `MainActivity.java` file and make the following changes:
324-
325-
```java
326-
@Override
327-
protected List<ReactPackage> getPackages() {
328-
return Arrays.<ReactPackage>asList(
329-
...
330-
new CodePush(BuildConfig.CODEPUSH_KEY, this, BuildConfig.DEBUG), // Add/change this line.
331-
...
332-
);
333-
}
334-
```
335-
336-
*Note: If you gave your build setting a different name in your Gradle file, simply make sure to reflect that in your Java code.*
337-
338-
And that's it! Now when you run or build your app, your debug builds will automatically be configured to sync with your `Staging` deployment, and your release builds will be configured to sync with your `Production` deployment.
339-
340-
*NOTE: By default, the `react-native run-android` command builds and deploys the debug version of your app, so if you want to test out a release/production build, simply run `react-native run-android --variant release. Refer to the [React Native docs](http://facebook.github.io/react-native/docs/signed-apk-android.html#conten) for details about how to configure and create release builds for your Android apps.*
341-
342-
If you want to be able to install both debug and release builds simultaneously on the same device (highly recommended!), then you need to ensure that your debug build has a unique identity and icon from your release build. Otherwise, neither the OS nor you will be able to differentiate between the two. You can achieve this by performing the following steps:
343-
344-
1. In your `build.gradle` file, specify the [`applicationIdSuffix`](http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html#com.android.build.gradle.internal.dsl.BuildType:applicationIdSuffix) field for your debug build type, which gives your debug build a unique identity for the OS (e.g. `com.foo` vs. `com.foo.debug`).
345-
346-
```groovy
347-
buildTypes {
348-
debug {
349-
applicationIdSuffix ".debug"
350-
}
351-
}
352-
```
353-
354-
2. Create the `app/src/debug/res` directory structure in your app, which allows overriding resources (e.g. strings, icons, layouts) for your debug builds
355-
356-
3. Create a `values` directory underneath the debug res directory created in #2, and copy the existing `strings.xml` file from the `app/src/main/res/values` directory
357-
358-
4. Open up the new debug `strings.xml` file and change the `<string name="app_name">` element's value to something else (e.g. `foo-debug`). This ensures that your debug build now has a distinct display name, so that you can differentiate it from your release build.
359-
360-
5. Optionally, create "mirrored" directories in the `app/src/debug/res` directory for all of your app's icons that you want to change for your debug build. This part isn't technically critical, but it can make it easier to quickly spot your debug builds on a device if its icon is noticeable different.
361-
362-
And that's it! View [here](http://tools.android.com/tech-docs/new-build-system/resource-merging) for more details on how resource merging works in Android.
363-
364-
### iOS
365-
366-
Xcode allows you to define custom build settings for each "configuration" (e.g. debug, release), which can then be referenced as the value of keys within the `Info.plist` file (e.g. the `CodePushDeploymentKey` setting). This mechanism allows you to easily configure your builds to produce binaries, which are configured to synchronize with different CodePush deployments.
367-
368-
To set this up, perform the following steps:
369-
370-
1. Open up your Xcode project and select your project in the `Project navigator` window
371-
372-
2. Ensure the project node is selected, as opposed to one of your targets
373-
374-
3. Select the `Info` tab
375-
376-
4. Click the `+` button within the `Configurations` section and select `Duplicate "Release" Configuration`
377-
378-
![Configuration](https://cloud.githubusercontent.com/assets/116461/16101597/088714c0-331c-11e6-9504-5469d9a59d74.png)
379-
380-
5. Name the new configuration `Staging` (or whatever you prefer)
381-
382-
6. Select the `Build Settings` tab
383-
384-
7. Go to `Build Location -> Per-configuration Build Products Path -> Staging` and change `Staging` value from `$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)` to `$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)`
385-
386-
![BuildFilesPath](https://cloud.githubusercontent.com/assets/4928157/22645377/b1d7df0e-ec77-11e6-83c6-291a27bcdb17.png)
387-
388-
*NOTE: Due to https://github.com/facebook/react-native/issues/11813, we have to do this step to make it possible to use other configurations than Debug or Release on RN 0.40.0 or higher.*
389-
390-
8. Click the `+` button on the toolbar and select `Add User-Defined Setting`
391-
392-
![Setting](https://cloud.githubusercontent.com/assets/116461/15764165/a16dbe30-28dd-11e6-94f2-fa3b7eb0c7de.png)
393-
394-
9. Name this new setting something like `CODEPUSH_KEY`, expand it, and specify your `Staging` deployment key for the `Staging` config and your `Production` deployment key for the `Release` config.
395-
396-
![Setting Keys](https://cloud.githubusercontent.com/assets/8598682/16821919/fc1eac4a-490d-11e6-9b11-128129c24b80.png)
397-
398-
*NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
399-
400-
10. Open your project's `Info.plist` file and change the value of your `CodePushDeploymentKey` entry to `$(CODEPUSH_KEY)`
401-
402-
![Infoplist](https://cloud.githubusercontent.com/assets/116461/15764252/3ac8aed2-28de-11e6-8c19-2270ae9857a7.png)
403-
404-
And that's it! Now when you run or build your app, your staging builds will automatically be configured to sync with your `Staging` deployment, and your release builds will be configured to sync with your `Production` deployment.
405-
406-
*Note: If you encounter the error message `ld: library not found for ...`, please consult [this issue](https://github.com/Microsoft/react-native-code-push/issues/426) for a possible solution.*
407-
408-
Additionally, if you want to give them seperate names and/or icons, you can modify the `Product Bundle Identifier`, `Product Name` and `Asset Catalog App Icon Set Name` build settings, which will allow your staging builds to be distinguishable from release builds when installed on the same device.
409268
410269
### Dynamic Deployment Assignment
411270
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
### Android
2+
3+
The [Android Gradle plugin](http://google.github.io/android-gradle-dsl/current/index.html) allows you to define custom config settings for each "build type" (e.g. debug, release), which in turn are generated as properties on the `BuildConfig` class that you can reference from your Java code. This mechanism allows you to easily configure your debug builds to use your CodePush staging deployment key and your release builds to use your CodePush production deployment key.
4+
5+
To set this up, perform the following steps:
6+
7+
1. Open your app's `build.gradle` file (e.g. `android/app/build.gradle` in standard React Native projects)
8+
9+
2. Find the `android { buildTypes {} }` section and define `buildConfigField` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively. If you prefer, you can define the key literals in your `gradle.properties` file, and then reference them here. Either way will work, and it's just a matter of personal preference.
10+
11+
```groovy
12+
android {
13+
...
14+
buildTypes {
15+
debug {
16+
...
17+
// Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
18+
buildConfigField "String", "CODEPUSH_KEY", '""'
19+
...
20+
}
21+
22+
releaseStaging {
23+
...
24+
buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_STAGING_KEY>"'
25+
...
26+
}
27+
28+
release {
29+
...
30+
buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_PRODUCTION_KEY>"'
31+
...
32+
}
33+
}
34+
...
35+
}
36+
```
37+
38+
*NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
39+
40+
*NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
41+
42+
4. Pass the deployment key to the `CodePush` constructor via the build config you just defined, as opposed to a string literal.
43+
44+
**For React Native >= v0.29**
45+
46+
Open up your `MainApplication.java` file and make the following changes:
47+
48+
```java
49+
@Override
50+
protected List<ReactPackage> getPackages() {
51+
return Arrays.<ReactPackage>asList(
52+
...
53+
new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
54+
...
55+
);
56+
}
57+
```
58+
59+
**For React Native v0.19 - v0.28**
60+
61+
Open up your `MainActivity.java` file and make the following changes:
62+
63+
```java
64+
@Override
65+
protected List<ReactPackage> getPackages() {
66+
return Arrays.<ReactPackage>asList(
67+
...
68+
new CodePush(BuildConfig.CODEPUSH_KEY, this, BuildConfig.DEBUG), // Add/change this line.
69+
...
70+
);
71+
}
72+
```
73+
74+
*Note: If you gave your build setting a different name in your Gradle file, simply make sure to reflect that in your Java code.*
75+
76+
And that's it! Now when you run or build your app, your debug builds will automatically be configured to sync with your `Staging` deployment, and your release builds will be configured to sync with your `Production` deployment.
77+
78+
*NOTE: By default, the `react-native run-android` command builds and deploys the debug version of your app, so if you want to test out a release/production build, simply run `react-native run-android --variant release. Refer to the [React Native docs](http://facebook.github.io/react-native/docs/signed-apk-android.html#conten) for details about how to configure and create release builds for your Android apps.*
79+
80+
If you want to be able to install both debug and release builds simultaneously on the same device (highly recommended!), then you need to ensure that your debug build has a unique identity and icon from your release build. Otherwise, neither the OS nor you will be able to differentiate between the two. You can achieve this by performing the following steps:
81+
82+
1. In your `build.gradle` file, specify the [`applicationIdSuffix`](http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html#com.android.build.gradle.internal.dsl.BuildType:applicationIdSuffix) field for your debug build type, which gives your debug build a unique identity for the OS (e.g. `com.foo` vs. `com.foo.debug`).
83+
84+
```groovy
85+
buildTypes {
86+
debug {
87+
applicationIdSuffix ".debug"
88+
}
89+
}
90+
```
91+
92+
2. Create the `app/src/debug/res` directory structure in your app, which allows overriding resources (e.g. strings, icons, layouts) for your debug builds
93+
94+
3. Create a `values` directory underneath the debug res directory created in #2, and copy the existing `strings.xml` file from the `app/src/main/res/values` directory
95+
96+
4. Open up the new debug `strings.xml` file and change the `<string name="app_name">` element's value to something else (e.g. `foo-debug`). This ensures that your debug build now has a distinct display name, so that you can differentiate it from your release build.
97+
98+
5. Optionally, create "mirrored" directories in the `app/src/debug/res` directory for all of your app's icons that you want to change for your debug build. This part isn't technically critical, but it can make it easier to quickly spot your debug builds on a device if its icon is noticeable different.
99+
100+
And that's it! View [here](http://tools.android.com/tech-docs/new-build-system/resource-merging) for more details on how resource merging works in Android.

docs/multi-deployment-testing-ios.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
### iOS
2+
3+
Xcode allows you to define custom build settings for each "configuration" (e.g. debug, release), which can then be referenced as the value of keys within the `Info.plist` file (e.g. the `CodePushDeploymentKey` setting). This mechanism allows you to easily configure your builds to produce binaries, which are configured to synchronize with different CodePush deployments.
4+
5+
To set this up, perform the following steps:
6+
7+
1. Open up your Xcode project and select your project in the `Project navigator` window
8+
9+
2. Ensure the project node is selected, as opposed to one of your targets
10+
11+
3. Select the `Info` tab
12+
13+
4. Click the `+` button within the `Configurations` section and select `Duplicate "Release" Configuration`
14+
15+
![Configuration](https://cloud.githubusercontent.com/assets/116461/16101597/088714c0-331c-11e6-9504-5469d9a59d74.png)
16+
17+
5. Name the new configuration `Staging` (or whatever you prefer)
18+
19+
6. Select the `Build Settings` tab
20+
21+
7. Go to `Build Location -> Per-configuration Build Products Path -> Staging` and change `Staging` value from `$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)` to `$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)`
22+
23+
![BuildFilesPath](https://cloud.githubusercontent.com/assets/4928157/22645377/b1d7df0e-ec77-11e6-83c6-291a27bcdb17.png)
24+
25+
*NOTE: Due to https://github.com/facebook/react-native/issues/11813, we have to do this step to make it possible to use other configurations than Debug or Release on RN 0.40.0 or higher.*
26+
27+
8. Click the `+` button on the toolbar and select `Add User-Defined Setting`
28+
29+
![Setting](https://cloud.githubusercontent.com/assets/116461/15764165/a16dbe30-28dd-11e6-94f2-fa3b7eb0c7de.png)
30+
31+
9. Name this new setting something like `CODEPUSH_KEY`, expand it, and specify your `Staging` deployment key for the `Staging` config and your `Production` deployment key for the `Release` config.
32+
33+
![Setting Keys](https://cloud.githubusercontent.com/assets/8598682/16821919/fc1eac4a-490d-11e6-9b11-128129c24b80.png)
34+
35+
*NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
36+
37+
10. Open your project's `Info.plist` file and change the value of your `CodePushDeploymentKey` entry to `$(CODEPUSH_KEY)`
38+
39+
![Infoplist](https://cloud.githubusercontent.com/assets/116461/15764252/3ac8aed2-28de-11e6-8c19-2270ae9857a7.png)
40+
41+
And that's it! Now when you run or build your app, your staging builds will automatically be configured to sync with your `Staging` deployment, and your release builds will be configured to sync with your `Production` deployment.
42+
43+
*Note: If you encounter the error message `ld: library not found for ...`, please consult [this issue](https://github.com/Microsoft/react-native-code-push/issues/426) for a possible solution.*
44+
45+
Additionally, if you want to give them seperate names and/or icons, you can modify the `Product Bundle Identifier`, `Product Name` and `Asset Catalog App Icon Set Name` build settings, which will allow your staging builds to be distinguishable from release builds when installed on the same device.

0 commit comments

Comments
 (0)