Repository navigation
Conversation
On macOS, for React Native 0.87 and later, `init` now runs React Native's Swift Package Manager setup (`setup-apple-spm add --deintegrate --yes`) after dependencies are installed, instead of installing CocoaPods. `--skip-spm` keeps the CocoaPods setup. `--install-pods true` without `--skip-spm` is an error where the setup would run. A failed setup prints a warning and a retry command; init still finishes.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
React Native plans to make Swift Package Manager the default iOS dependency setup in 0.89, with CocoaPods as an opt-out. Today
initalways sets up a new app with CocoaPods, so a new app does not get the default.This PR changes
initon macOS, for React Native 0.87 and later:initruns React Native's own setup script:setup-apple-spm add --deintegrate --yes. It removes the template's CocoaPods setup and adds the Swift Package Manager setup. The pod install step and its prompt do not run.--skip-spm, keeps the CocoaPods setup.--install-podsthen works as before.--install-pods truewithout--skip-spmis an error where the setup would run, so scripts see the conflict instead of a silent change.initprints a warning and the command to retry, and finishes. This is the same as a failed pod install today.--skip-install,initprints the setup command to run later.Nothing changes on Linux or Windows, or for React Native 0.86 and earlier. With
--templateor an out-of-tree--platform-name,initdoes not know the React Native version up front:--install-pods truekeeps CocoaPods there, and otherwise the setup runs if the installed React Native has the script.run-iosandbuild-iosalready detect a Swift Package Manager project (#2858), so they work on the new app without a Podfile install.Depends on: react/react-native#59368 (
spm deinit, the way back to CocoaPods for an existing app). This PR is a draft until that lands. The code does not calldeinit.Test Plan
Unit tests:
Result: 7 suites, 96 tests pass. New:
__tests__/spm.test.ts,__tests__/init.test.ts(throughinitialize),__tests__/printRunInstructions.test.ts.yarn lintandyarn build:tspass.End-to-end, with a local build of this branch, Xcode 27.1, CocoaPods 1.16.2:
initon RN 0.88.1initon RN 0.87.1init --skip-spminit --install-pods trueinitwith nopodon PATHNot tested: React Native 0.89 (not released).
Checklist
react-nativecheckout (instructions). Tested with a local CLI build on fresh apps from released React Native versions instead.