Skip to content

Commit 4116589

Browse files
committed
refactor: apply code review feedback
- Change bridgingHeaderPath to bridgingHeaderFile - Add bridging header manual setup reference link - Fix expo setup readme order
1 parent 6747661 commit 4116589

File tree

3 files changed

+39
-37
lines changed

3 files changed

+39
-37
lines changed

README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,7 @@ The following changes are optional but recommended for cleaning up the old confi
3535
npm install @bravemobile/react-native-code-push
3636
```
3737

38-
### 2. Expo Setup
39-
For Expo projects, you can use the automated config plugin instead of manual setup.
40-
41-
**Add plugin to your Expo configuration:**
42-
```js
43-
// app.config.js
44-
export default {
45-
expo: {
46-
plugins: ["@bravemobile/react-native-code-push"],
47-
},
48-
};
49-
```
50-
51-
**Run prebuild to apply changes:**
52-
```bash
53-
npx expo prebuild
54-
```
55-
56-
>[!NOTE] The plugin automatically handles all native iOS and Android code modifications. No manual editing of AppDelegate, MainApplication, or gradle files is required.
57-
58-
**Requirements**
59-
Expo SDK: 50.0.0 or higher
60-
61-
### 3. iOS Setup
38+
### 2. iOS Setup
6239

6340
#### (1) Install CocoaPods Dependencies
6441

@@ -133,7 +110,7 @@ Then, edit `AppDelegate.swift` like below.
133110
```
134111

135112

136-
### 4. Android Setup
113+
### 3. Android Setup
137114

138115
#### (1) Edit `android/app/build.gradle`
139116

@@ -184,6 +161,30 @@ Add the following line to the end of the file.
184161
}
185162
```
186163

164+
### 4. Expo Setup
165+
For Expo projects, you can use the automated config plugin instead of manual setup.
166+
167+
**Add plugin to your Expo configuration:**
168+
```js
169+
// app.config.js
170+
export default {
171+
expo: {
172+
plugins: ["@bravemobile/react-native-code-push"],
173+
},
174+
};
175+
```
176+
177+
**Run prebuild to apply changes:**
178+
```bash
179+
npx expo prebuild
180+
```
181+
182+
> [!NOTE]
183+
> The plugin automatically handles all native iOS and Android code modifications. No manual editing of AppDelegate, MainApplication, or gradle files is required.
184+
185+
**Requirements**
186+
Expo SDK: 50.0.0 or higher
187+
187188
### 5. "CodePush-ify" Your App
188189

189190
The root component of your app should be wrapped with a higher-order component.

expo/plugin/withCodePushAndroid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function androidMainApplicationApplyImplementation(
3131
Please add "${add.replace(/\n/g, '').trim()}" to the MainApplication.kt.
3232
Supported format: Expo SDK default template.
3333
34-
Android manual setup: https://github.com/Soomgo-Mobile/react-native-code-push#4-android-setup
34+
Android manual setup: https://github.com/Soomgo-Mobile/react-native-code-push#3-android-setup
3535
`,
3636
);
3737

expo/plugin/withCodePushIos.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ function iosApplyImplementation(
2424
Please ${replace ? 'replace' : 'add'} "${add.replace(/\n/g, '').trim()}" to the AppDelegate.(m|swift).
2525
Supported format: Expo SDK default template.
2626
27-
iOS manual setup: https://github.com/Soomgo-Mobile/react-native-code-push#3-ios-setup
27+
iOS manual setup: https://github.com/Soomgo-Mobile/react-native-code-push#2-ios-setup
2828
`,
2929
);
3030

3131
return appDelegate;
3232
}
3333

34-
function getBridgingHeaderPathFromXcode(project) {
34+
function getBridgingHeaderFileFromXcode(project) {
3535
const buildConfigs = project.pbxXCBuildConfigurationSection();
3636

3737
for (const key in buildConfigs) {
@@ -41,11 +41,11 @@ function getBridgingHeaderPathFromXcode(project) {
4141
config.buildSettings &&
4242
config.buildSettings['SWIFT_OBJC_BRIDGING_HEADER']
4343
) {
44-
const bridgingHeaderPath = config.buildSettings[
44+
const bridgingHeaderFile = config.buildSettings[
4545
'SWIFT_OBJC_BRIDGING_HEADER'
4646
].replace(/"/g, '');
4747

48-
return bridgingHeaderPath;
48+
return bridgingHeaderFile;
4949
}
5050
}
5151
return null;
@@ -97,22 +97,22 @@ const withIosBridgingHeader = (config) => {
9797
const appDelegate = getAppDelegate(projectRoot);
9898

9999
if (appDelegate.language === 'swift') {
100-
const bridgingHeaderPath = getBridgingHeaderPathFromXcode(
100+
const bridgingHeaderFile = getBridgingHeaderFileFromXcode(
101101
action.modResults,
102102
);
103103

104-
const bridgingHeaderFilePath = path.join(
104+
const bridgingHeaderPath = path.join(
105105
action.modRequest.platformProjectRoot,
106-
bridgingHeaderPath,
106+
bridgingHeaderFile,
107107
);
108108

109-
if (fs.existsSync(bridgingHeaderFilePath)) {
110-
let content = fs.readFileSync(bridgingHeaderFilePath, 'utf8');
109+
if (fs.existsSync(bridgingHeaderPath)) {
110+
let content = fs.readFileSync(bridgingHeaderPath, 'utf8');
111111
const codePushImport = '#import <CodePush/CodePush.h>';
112112

113113
if (!content.includes(codePushImport)) {
114114
content += `${codePushImport}\n`;
115-
fs.writeFileSync(bridgingHeaderFilePath, content);
115+
fs.writeFileSync(bridgingHeaderPath, content);
116116
}
117117

118118
return action;
@@ -121,11 +121,12 @@ const withIosBridgingHeader = (config) => {
121121
WarningAggregator.addWarningIOS(
122122
'withIosBridgingHeader',
123123
`
124-
Failed to detect ${bridgingHeaderFilePath} file.
124+
Failed to detect ${bridgingHeaderPath} file.
125125
Please add CodePush integration manually:
126126
#import <CodePush/CodePush.h>
127127
128128
Supported format: Expo SDK default template.
129+
iOS manual setup: https://github.com/Soomgo-Mobile/react-native-code-push#2-edit-appdelegate-code
129130
`
130131
);
131132

0 commit comments

Comments
 (0)