|
4 | 4 |
|
5 | 5 | ### Plugin Installation and Configuration |
6 | 6 |
|
7 | | -1. Run `cd ios && pod install && cd ..` to install all the necessary CocoaPods dependencies. |
| 7 | +1. Run `cd ios && pod install && cd ..` to install all the necessary CocoaPods dependencies. You may have to change the `Podfile`'s min iOS version to 15.5 (`platform :ios, '15.5'`). |
8 | 8 |
|
9 | | -2. Open up the `AppDelegate.m`/`AppDelegate.swift` file, and add an import statement for the CodePush headers: |
10 | | - |
11 | | - ```objective-c |
12 | | - #import <CodePush/CodePush.h> |
13 | | - ``` |
| 9 | +2. Open up the `AppDelegate.swift`/`AppDelegate.m` file, and add an import statement for the CodePush headers: |
14 | 10 |
|
15 | 11 | ```swift |
16 | 12 | import CodePush |
17 | 13 | ``` |
18 | 14 |
|
19 | | -3. Find the following line of code, which sets the source URL for bridge for production releases: |
20 | | - |
21 | 15 | ```objective-c |
22 | | - return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; |
| 16 | + #import <CodePush/CodePush.h> |
23 | 17 | ``` |
24 | 18 |
|
| 19 | +3. Find the following line of code, which sets the source URL for bridge for production releases: |
| 20 | + |
25 | 21 | ```swift |
26 | 22 | Bundle.main.url(forResource: "main", withExtension: "jsbundle") |
27 | 23 | ``` |
28 | 24 |
|
29 | | -4. Replace it with this line: |
30 | | - |
31 | 25 | ```objective-c |
32 | | - return [CodePush bundleURL]; |
| 26 | + return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; |
33 | 27 | ``` |
34 | 28 |
|
| 29 | +4. Replace it with this line: |
| 30 | +
|
35 | 31 | ```swift |
36 | 32 | CodePush.bundleURL() |
37 | 33 | ``` |
38 | 34 |
|
| 35 | + ```objective-c |
| 36 | + return [CodePush bundleURL]; |
| 37 | + ``` |
| 38 | + |
39 | 39 | This change configures your app to always load the most recent version of your app's JS bundle. On the first launch, this will correspond to the file that was compiled with the app. However, after an update has been pushed via CodePush, this will return the location of the most recently installed update. |
40 | 40 |
|
41 | 41 | _NOTE: The `bundleURL` method assumes your app's JS bundle is named `main.jsbundle`. If you have configured your app to use a different file name, simply call the `bundleURLForResource:` method (which assumes you're using the `.jsbundle` extension) or `bundleURLForResource:withExtension:` method instead, in order to overwrite that default behavior_ |
|
44 | 44 |
|
45 | 45 | Your `sourceURLForBridge` method should look like this: |
46 | 46 |
|
| 47 | + ```swift |
| 48 | + override func bundleURL() -> URL? { |
| 49 | + #if DEBUG |
| 50 | + RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index") |
| 51 | + #else |
| 52 | + CodePush.bundleURL() |
| 53 | + #endif |
| 54 | + } |
| 55 | + ``` |
| 56 | + |
47 | 57 | ```objective-c |
48 | 58 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge |
49 | 59 | { |
|
55 | 65 | } |
56 | 66 | ``` |
57 | 67 |
|
58 | | - ```swift |
59 | | - override func bundleURL() -> URL? { |
60 | | - #if DEBUG |
61 | | - RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index") |
62 | | - #else |
63 | | - CodePush.bundleURL() |
64 | | - #endif |
65 | | - } |
66 | | - ``` |
67 | | - |
68 | 68 | 5. Add the Release channel public ID to `Info.plist`: |
69 | 69 |
|
70 | 70 | To let the CodePush runtime know which release channel it should query for updates against, open your app's `Info.plist` file and add a new entry named `CodePushReleaseChannelPublicId`, whose value is the public ID of the release channel you want to configure this app against. You can retrieve this value by running `appzung release-channels list` in the AppZung CLI and copying the value of the `Public ID` column. |
|
0 commit comments