Repository navigation
fix: support Expo modules in React Native CLI apps #487
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
Merged
hurali97
merged 13 commits into
callstack:main
from
KisaneNeko:fix/cli-skip-prebuild-bare-expo
Oct 16, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
531bcca
fix(cli): skip expo prebuild in React Native CLI apps using Expo modules
KisaneNeko c201665
feat(scaffold): set up the Expo host for React Native CLI apps using …
KisaneNeko b70b824
fix(cli): make precompiled Expo work in React Native CLI apps
KisaneNeko 179f5cc
fix(cli): copy symlinked Expo XCFrameworks as real files
KisaneNeko e0f5940
docs(changeset): note when expo prebuild no longer runs
KisaneNeko fff5e51
fix: address review feedback on Expo setup and precompiled defaults
KisaneNeko edfc478
test: cover Podfile properties check and double-quoted Podfile targets
KisaneNeko 8f44836
fix(scaffold): don't duplicate the Sources phase after pod install
KisaneNeko 3f1560c
docs: make the Expo modules iOS steps easier to follow
KisaneNeko 0b3fba2
docs: move Expo modules setup for RN CLI apps to its own guide
KisaneNeko 9639694
Merge remote-tracking branch 'origin/main' into fix/cli-skip-prebuild…
KisaneNeko 12b80db
feat(scaffold): raise an existing framework target to iOS 16.4 for Expo
KisaneNeko 9847a70
feat(scaffold): generate package:ios with --add-spm-package
KisaneNeko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| '@callstack/brownfield-cli': patch | ||
| '@callstack/react-native-brownfield': patch | ||
| '@callstack/create-react-native-brownfield': patch | ||
| --- | ||
|
|
||
| Support Expo modules in React Native CLI apps. `brownfield package:*` no longer runs `expo prebuild` on projects with committed `android/` and `ios/` directories, which used to delete the brownfield library module. Prebuild now runs only when the native directory is missing or gitignored. If you commit the generated directories of an Expo app, run `npx expo prebuild` yourself after changing `app.json` or config plugins. `create-react-native-brownfield` now detects Expo and sets up the iOS framework to use the Expo runtime. On a re-run after adding Expo, it also raises an existing framework target to iOS 16.4. | ||
|
|
||
| `--use-prebuilt-expo` now also turns Expo's precompiled modules on or off for `pod install`, and turns on Swift explicit modules so packaging works in projects that still carry the old `SWIFT_ENABLE_EXPLICIT_MODULES = NO` workaround. It defaults to building Expo from source when the app's React Native version doesn't match the one Expo's precompiled modules were built for. | ||
|
|
||
| `package:ios` now copies the expo-image dependency XCFrameworks (SDWebImage and libavif) as real files instead of symlinks into `node_modules`, so the package works when moved to another machine. | ||
|
|
||
| Re-running `create-react-native-brownfield` after `pod install` no longer adds a second Sources build phase to the framework target, which made the next `pod install` fail. | ||
|
|
||
| The `package:ios` script that `create-react-native-brownfield` adds now passes `--add-spm-package`, so the iOS app adds one local Swift package instead of every XCFramework. Existing scripts aren't changed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| [ | ||
| "guidelines", | ||
| "minification", | ||
| "expo-modules", | ||
| "performance-metrics", | ||
| "troubleshooting", | ||
| { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { PackageManagerTabs } from '@theme'; | ||
|
|
||
| # Expo Modules in React Native CLI Apps | ||
|
|
||
| This guide is for React Native Community CLI apps that use Expo modules, such as `expo-image`, installed with `npx install-expo-modules`. Apps without Expo modules don't need any of these steps. Expo apps that use `expo prebuild` should follow [Expo Integration](/docs/getting-started/expo) instead. | ||
|
|
||
| Complete [React Native CLI Integration](/docs/getting-started/rnc-cli) first. The Brownfield CLI then packages Expo modules with the rest of your app. | ||
|
|
||
| ## Android | ||
|
|
||
| No extra setup is needed. If your app has product flavors, see [Troubleshooting](/docs/guides/troubleshooting) for setting `missingDimensionStrategy`. | ||
|
|
||
| ## iOS | ||
|
|
||
| On iOS, Expo modules only work when React Native starts through Brownfield's Expo runtime. You set this up once in your React Native project, then update your native iOS app. | ||
|
|
||
| ### In your React Native project | ||
|
|
||
| 1. Install Expo modules with `npx install-expo-modules`, if you haven't already. It also raises the `platform :ios` line in `ios/Podfile` to iOS 16.4, which Expo SDK 56 and newer require. | ||
| 2. From the project root, run the command from [Automated Setup](/docs/getting-started/rnc-cli#automated-setup). If you ran it before you added Expo, run it again. It only changes what's missing. | ||
|
|
||
| <PackageManagerTabs command="create @callstack/react-native-brownfield@latest" /> | ||
|
|
||
| Because your `package.json` depends on `expo`, the command: | ||
| - adds `ENV['REACT_NATIVE_BROWNFIELD_USE_EXPO_HOST'] = '1'` to the framework target in `ios/Podfile` | ||
| - adds `ensureExpoModulesProvider()` to `ios/<framework_target_name>/<framework_target_name>.swift` | ||
| - raises the framework target to iOS 16.4 if it uses an older version | ||
|
|
||
| 3. Package your app as a local Swift package: | ||
|
|
||
| <PackageManagerTabs command="run package:ios" /> | ||
|
|
||
| The `package:ios` script from the setup command passes `--add-spm-package`. If your script was added before that, run `npx brownfield package:ios --add-spm-package` instead. | ||
|
|
||
| Expo's precompiled modules only work with the React Native version your Expo SDK targets. With a different version, Brownfield builds them from source. See [Expo Prebuilts](/docs/getting-started/ios#expo-prebuilts). | ||
|
|
||
| ### In your native iOS app | ||
|
|
||
| 1. Add the package. It includes your framework, React Native and every Expo framework, so you don't have to add XCFrameworks one by one: | ||
| 1. In Xcode, choose **File > Add Package Dependencies...**, click **Add Local...** and select `ios/.brownfield/package/build`. | ||
| 2. In your app target's **General** tab, add the `<framework_target_name>` product under **Frameworks, Libraries, and Embedded Content**. | ||
|
|
||
| If you'd rather add the XCFrameworks by hand, run `npx brownfield package:ios` without `--add-spm-package` and follow [Add the Framework to Your iOS App](/docs/getting-started/ios#7-add-the-framework-to-your-ios-app). | ||
|
|
||
| 2. Call `ensureExpoModulesProvider()` before you start React Native: | ||
|
|
||
| ```swift | ||
| ReactNativeBrownfield.shared.bundle = ReactNativeBundle | ||
| ReactNativeBrownfield.shared.ensureExpoModulesProvider() | ||
| ReactNativeBrownfield.shared.startReactNative { _ in | ||
| print("React Native has been loaded") | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 there a possibility to have the manual steps collapsed into brownfield CLI? For example, using
spminstead of manual linking the frameworks?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.
Thanks Hur, good call! The setup command now raises the framework target to iOS 16.4, and the
package:iosscript it generates builds a local Swift package by default, so the host app adds one package instead of dragging in every XCFramework. I tested it with expo-image in a fresh Xcode app.The host app still needs a one-time step to add that package in Xcode (plus the
ensureExpoModulesProvider()call Expo apps already make). I didn't want to make the CLI edit the host app's Xcode project in this PR. It's doable, but I'm worried it'd be hard to get right for every setup. We could give it a try as a separate PR.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.
Awesome, thanks!