Skip to content

Make spm add --deintegrate work without CocoaPods installed - #60422

Open
chrfalch wants to merge 1 commit into
mainfrom
spm-deintegrate-without-pod
Open

chrfalch wants to merge 1 commit into
mainfrom
spm-deintegrate-without-pod

Conversation

@chrfalch

@chrfalch chrfalch commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Summary:

setup-apple-spm add --deintegrate converts an iOS app from CocoaPods to Swift Package Manager. It ran pod deintegrate, so it failed on a Mac without the pod tool. A new app's template project contains CocoaPods references, and plain add refuses such a project. So converting a new app to Swift Package Manager required CocoaPods to be installed.

With this change, when pod is not installed, the script removes the CocoaPods references from project.pbxproj itself:

  • the [CP] build phases,
  • the Pods library and Pods-*.xcconfig references,
  • the empty Pods group.

It deletes no files on disk. When pod is installed, pod deintegrate runs as before.

If references remain that the script does not recognise, it changes nothing and exits with an error. One example is the newer CocoaPods 1.16 baseConfigurationReferenceAnchor form. The error says to install CocoaPods and run the command again, or to remove the remaining references by hand. The help text and the docs now say that CocoaPods is used when installed and is not required.

Code: removeCocoaPodsIntegration in packages/react-native/scripts/spm/spm-pbxproj.js. It is used by runDeintegrate in packages/react-native/scripts/setup-apple-spm.js. The test fixture __tests__/__fixtures__/cocoapods-app.pbxproj is a CocoaPods-integrated project with two targets.

Changelog:

[IOS] [ADDED] - spm add --deintegrate works without CocoaPods installed

Test Plan:

  • yarn test packages/react-native/scripts/spm: 25 of 25 suites and 1275 of 1275 tests passed. The new tests failed before the change.
  • yarn flow-check: 0 errors.
  • yarn eslint --max-warnings 0 on the changed files: clean.
  • Same output as CocoaPods: on copies of private/helloworld and the community template project, the new function's output is byte-identical to the output of bundle exec pod deintegrate (CocoaPods 1.14.2) followed by the existing empty-Pods-group cleanup.
  • Build check on a Mac without pod on PATH: private/helloworld was converted with spm add --deintegrate, as .github/workflows/test-ios-spm-newapp.yml does. xcodebuild (Debug, generic iOS Simulator) then printed BUILD SUCCEEDED.
  • Not run: a full device build, and a project that already uses the CocoaPods 1.16 anchor form. A unit test covers the anchor form: the script leaves the project unchanged and exits with code 1.

`setup-apple-spm add --deintegrate` ran `pod deintegrate` and failed when the
`pod` tool was not on PATH. A new app's template project carries CocoaPods
references, so converting it to Swift Package Manager failed on a Mac without
CocoaPods.

When `pod` is missing, the script now removes the CocoaPods references from
project.pbxproj itself: the [CP] build phases, the Pods library and xcconfig
references, and the empty Pods group. For the template and helloworld projects
the result is byte-identical to `pod deintegrate`. It deletes no files on disk.
If references remain that it does not know (such as the CocoaPods 1.16 anchor
form), it changes nothing and exits with advice to install CocoaPods or remove
them by hand. When `pod` is installed, `pod deintegrate` runs as before.

Verify: `yarn test packages/react-native/scripts/spm` passes 1275 of 1275 tests.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 1, 2026
@facebook-github-tools facebook-github-tools Bot added p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Dec 1, 2026
@chrfalch
chrfalch marked this pull request as draft December 1, 2026 07:41
@chrfalch
chrfalch marked this pull request as ready for review December 1, 2026 08:43
@chrfalch
chrfalch requested a review from cipolleschi December 1, 2026 09:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant