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
Open
KisaneNeko
wants to merge
10
commits into
callstack:main
Choose a base branch
from
KisaneNeko:fix/cli-skip-prebuild-bare-expo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+938
−48
Open
Changes from all commits
Commits
Show all changes
10 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 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,13 @@ | ||
| --- | ||
| '@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. | ||
|
|
||
| `--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. |
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", | ||
| "troubleshooting", | ||
| { | ||
| "type": "dir", | ||
|
|
||
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,46 @@ | ||
| 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` | ||
|
|
||
| 3. Make sure the framework target uses iOS 16.4 or newer. Open `ios/<project>.xcworkspace` in Xcode, select the framework target, and check **Minimum Deployments**. Targets the command creates after Expo is installed already use 16.4. | ||
| 4. Package your app: | ||
|
|
||
| <PackageManagerTabs command="run package:ios" /> | ||
|
|
||
| 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 Expo XCFrameworks from `ios/.brownfield/package/build` along with your framework. [Add the Framework to Your iOS App](/docs/getting-started/ios#7-add-the-framework-to-your-ios-app) lists which ones you need. | ||
| 2. Call `ensureExpoModulesProvider()` before you start React Native: | ||
|
|
||
| ```swift | ||
| ReactNativeBrownfield.shared.bundle = ReactNativeBundle | ||
| ReactNativeBrownfield.shared.ensureExpoModulesProvider() | ||
| ReactNativeBrownfield.shared.startReactNative { | ||
| 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?