Skip to content

Commit e94873f

Browse files
committed
Add MainApplication.swift support
1 parent a188245 commit e94873f

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

CodePush.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Pod::Spec.new do |s|
1616
s.library = 'z'
1717
s.source_files = 'ios/CodePush/*.{h,m}'
1818
s.public_header_files = ['ios/CodePush/CodePush.h']
19+
s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES" }
1920

2021
# Note: Even though there are copy/pasted versions of some of these dependencies in the repo,
2122
# we explicitly let CocoaPods pull in the versions below so all dependencies are resolved and

docs/setup-android.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
2. Update the `MainApplication` file to use CodePush via the following changes:
1717
18-
For React Native 0.73 and above: update the `MainApplication.kt`
18+
If your MainApplication is a Kotlin file, update the `MainApplication.kt`
1919
2020
```kotlin
2121
...
@@ -38,7 +38,7 @@
3838
}
3939
```
4040
41-
For React Native 0.72 and below: update the `MainApplication.java`
41+
If your MainApplication is a Java file: update the `MainApplication.java`
4242
4343
```java
4444
...

docs/setup-ios.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,36 @@
66

77
1. Run `cd ios && pod install && cd ..` to install all the necessary CocoaPods dependencies.
88

9-
2. Open up the `AppDelegate.m` file, and add an import statement for the CodePush headers:
9+
2. Open up the `AppDelegate.m`/`AppDelegate.swift` file, and add an import statement for the CodePush headers:
1010

1111
```objective-c
1212
#import <CodePush/CodePush.h>
1313
```
14+
15+
```swift
16+
import CodePush
17+
```
1418

1519
3. Find the following line of code, which sets the source URL for bridge for production releases:
1620

1721
```objective-c
1822
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
1923
```
24+
25+
```swift
26+
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
27+
```
2028

2129
4. Replace it with this line:
2230

2331
```objective-c
2432
return [CodePush bundleURL];
2533
```
34+
35+
```swift
36+
CodePush.bundleURL()
37+
```
38+
2639
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.
2740

2841
*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*
@@ -41,6 +54,16 @@
4154
#endif
4255
}
4356
```
57+
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+
```
4467

4568
5. Add the Release channel public ID to `Info.plist`:
4669

0 commit comments

Comments
 (0)