Conversation
React Native 0.87's `react-native spm` migrates the Xcode project to Swift Package Manager and leaves the `Podfile` on disk, which left `config` without a `project.ios.sourceDir` and made `run-ios`/`build-ios` try to install pods. Look for the `.spm-injected.json` marker `react-native spm` writes inside the migrated `.xcodeproj`, expose `project.ios.buildSystem` and skip CocoaPods for those projects unless pods are explicitly requested. Closes #2856
|
Works for a sample app |
`init` pulls the latest React Native, which contributes a `spm [action]` command to the config output. `buildSystem` is not part of this snapshot: the e2e project resolves the iOS platform config through the CLI pinned in the React Native template, and the field is covered by the unit tests instead.
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
Fixes #2856
React Native 0.87 ships
react-native spm, which migrates the Xcode project to Swift Package Manager, strips React Native out of thePodfileand leaves the file on disk. We treated those projects as broken: with noPodfilefound,getProjectConfigbailed out, soconfighad noproject.ios.sourceDirandrun-ios/build-iosinsisted on installing pods.findSpmProjectDirlooks for the.xcodeprojcontaining.spm-injected.json— the markerreact-native spmwrites inside the project bundle, andreact-native spm deinitremoves. It wins over a leftoverPodfile, sincereact-native spmrefuses to migrate a CocoaPods-integrated project anyway.project.ios.buildSystemisspmorcocoapods, so commands know where React Native comes from.resolvePodsreturns whether pods were installed, instead of both callers settinginstalledPods = truenext to it, and skips CocoaPods forspmprojects.--force-pods/--only-podsstill run it, which is how pods unrelated to React Native keep working next to Swift Package Manager. Forcing pods where there is noPodfilenow errors with a hint to runreact-native spm.Libraries still need a
Package.swift, which is RN'sreact-native spm scaffold+patch-packagestory. Nothing to configure in the CLI anymore — noproject.ios.sourceDir, noautomaticPodsInstallation: false, no stubPodfile, e.g. the ones needed in bottom-tabs' SPM example.Test Plan
Verified against a real 0.87.1 app migrated with
node node_modules/react-native/scripts/setup-apple-spm.js add --deintegrate --yes, with this build linked intonode_modules:Debug and Release both build, install, launch and render the app; no CocoaPods step runs. RN's own
generate-spm-autolinking-config.jssucceeds against thisconfigoutput — before the change it failed withCLI config did not provide project.ios.sourceDir. A CocoaPods project's output is identical apart frombuildSystem: "cocoapods".The e2e config snapshot doesn't see the new field: that test
inits a project, which pulls@react-native-community/cli-platform-iosfrom the React Native template, so the iOS project config comes from the published CLI rather than this checkout. Its only update here is RN's newspm [action]command, which landed with 0.87 and is pre-existing drift rather than something from this change.One unrelated thing I tripped over:
run-ios --portstarts the dev server on that port, butinstallApplaunches the app with a baresimctl launch, so the app still asks the packager on 8081. I had to launch with-RCT_jsLocation localhost:8090to load my bundle. Worth a separate issue.Checklist
react-nativecheckout (instructions).