-
Notifications
You must be signed in to change notification settings - Fork 11
feat(expo): Add Expo config plugin for automated CodePush setup #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work.
Thanks for your contribution and the detailed description.
I’ve added a few comments.
feel free to check them out and let me know what you think.
"peerDependenciesMeta": { | ||
"expo": { | ||
"optional": true | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const { createRunOncePlugin } = require('expo/config-plugins'); | ||
const { withAndroidBuildScriptDependency, withAndroidMainApplicationDependency } = require('./withCodePushAndroid'); | ||
const { withIosBridgingHeader, withIosAppDelegateDependency } = require('./withCodePushIos'); | ||
const pkg = require('../../package.json'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it intend to refer to the @bravemobile/react-native-code-push
package?
Just curious.
action.modResults.contents = androidMainApplicationApplyImplementation( | ||
action.modResults.contents, | ||
'class MainApplication : Application(), ReactApplication {', | ||
'import com.microsoft.codepush.react.CodePush\n', | ||
true, | ||
); | ||
|
||
action.modResults.contents = androidMainApplicationApplyImplementation( | ||
action.modResults.contents, | ||
'object : DefaultReactNativeHost(this) {', | ||
' override fun getJSBundleFile(): String = CodePush.getJSBundleFile()\n', | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the MainApplication file written in Kotlin starting from Expo SDK 50?
Is there no need to support the case where it is written in Java?
@@ -35,7 +35,30 @@ The following changes are optional but recommended for cleaning up the old confi | |||
npm install @bravemobile/react-native-code-push | |||
``` | |||
|
|||
### 2. iOS Setup | |||
### 2. Expo Setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but since our team, as maintainers, doesn’t use Expo in our environment, supporting Expo has a lower priority compared to RN CLI projects.
Although Expo is recommended, our library still prioritizes RN CLI support.
so, please move the Expo setup instructions to come after the iOS/Android sections. 🙏
npx expo prebuild | ||
``` | ||
|
||
>[!NOTE] The plugin automatically handles all native iOS and Android code modifications. No manual editing of AppDelegate, MainApplication, or gradle files is required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>[!NOTE] The plugin automatically handles all native iOS and Android code modifications. No manual editing of AppDelegate, MainApplication, or gradle files is required. | |
> [!NOTE] | |
> The plugin automatically handles all native iOS and Android code modifications. No manual editing of AppDelegate, MainApplication, or gradle files is required. |
Note
The plugin automatically handles all native iOS and Android code modifications. No manual editing of AppDelegate, MainApplication, or gradle files is required.
'withIosBridgingHeader', | ||
` | ||
Failed to detect ${bridgingHeaderFilePath} file. | ||
Please add CodePush integration manually: | ||
#import <CodePush/CodePush.h> | ||
|
||
Supported format: Expo SDK default template. | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a good idea to add a reference link here as well.
e.g.
https://github.com/Soomgo-Mobile/react-native-code-push#2-edit-appdelegate-code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
action.modResults.contents = iosApplyImplementation( | ||
action.modResults.contents, | ||
`return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];`, | ||
`return [CodePush bundleURL];`, | ||
true, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just wondering..
Expo plugins probably don’t modify and commit changes to AppDelegate/MainApplication file.
If so, the code developers see might be different from what’s actually used at build time.
I think this could be confusing. Especially if someone tries to search the code.
And if someone modified the code, this plugin might not work correctly.
This plugin is great!
but from a maintenance perspective, I personally think it’s better for developers to update and manage their code manually.
No worries, this PR won't be rejected :)
const bridgingHeaderPath = config.buildSettings[ | ||
'SWIFT_OBJC_BRIDGING_HEADER' | ||
].replace(/"/g, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that value of bridgingHeaderPath
is a file name, not a path 🤔
I think it would be better to rename to bridgingHeaderFile
.
📝 Overview
This PR adds an Expo config plugin that automatically configures CodePush for Expo projects, eliminating the need for manual native code modifications. The plugin handles both iOS and Android platform setup through Expo's prebuild process.
✨ What's Added
README.md
)🎯 Usage
Installation
Configuration
Add the plugin to your Expo config:
app.config.js:
Build Process
# Prebuild to apply native changes npx expo prebuild
🚨 Error Handling
The plugin includes comprehensive warning systems:
✅ Platform Support
Android
iOS
✅ Testing
🔄 Breaking Changes
None - This is an additive feature that doesn't affect existing functionality.