Repository navigation
Commit bccb1df
Let
## Summary:
An app converted to SwiftPM cannot go back to CocoaPods today. The conversion deletes the React Native lines from the Podfile, one line at a time. A call that spans several lines, such as `use_react_native!(…)`, keeps its other lines, so the Podfile is no longer valid Ruby.
This PR keeps the Podfile unchanged. The way back to CocoaPods is then `npx react-native spm deinit`, followed by `pod install`.
What changes:
1. **`spm add --deintegrate` keeps the Podfile.** It runs `pod deintegrate` and nothing else on the Podfile.
2. **Plain `npx react-native spm` no longer converts a CocoaPods app.** It stops and points to `spm add --deintegrate`.
3. **`pod install` stops on a SwiftPM app.** The Podfile is still there, so a user can run `pod install` by mistake. That would add CocoaPods back and break the generated `Package.swift`. The React Native CocoaPods scripts now stop with an error, before they write any file, when the `.xcodeproj` has the SwiftPM marker file (`.spm-injected.json`).
4. **`spm deinit` cleans up after itself.** It removes the `.gitignore` lines that the conversion added, and the empty `ReactNativeSPM` folders. Then it says to run `pod install`.
Smaller fixes from the review:
- The uncommitted-changes prompt now comes before `pod deintegrate`, so "no" changes nothing.
- `.gitignore` is written only after a successful conversion.
- Pods that come from `node_modules/react-native` no longer show in the "pods that are not part of React Native" warning.
The three SwiftPM iOS CI workflows checked the Podfile content after the conversion. They now check that the `.xcodeproj` has no CocoaPods references.
Where to look:
- `scripts/setup-apple-spm.js`: the conversion and `deinit` (items 1, 2, 4).
- `scripts/cocoapods/utils.rb` (`error_if_spm_injected`), called from `react_native_pods.rb` and `cocoapods/autolinking.rb`: the `pod install` check (item 3).
## Changelog:
[IOS] [CHANGED] - `react-native spm add --deintegrate` keeps the Podfile, and `pod install` stops with an error on an app that uses SwiftPM. `react-native spm deinit` and then `pod install` take an app back to CocoaPods.
## Test Plan:
Unit tests:
```
yarn jest packages/react-native/scripts/spm/__tests__
```
25 suites, 1236 tests pass.
A new app on React Native 0.89.0-nightly-20261021-c7429b0e9 and CLI 21.0.0-alpha.1, with the changed scripts copied in:
1. `npx react-native spm add --deintegrate --yes`: the app converts, the Podfile is unchanged, and the SwiftPM build succeeds.
2. `pod install`: it stops with "This app uses Swift Package Manager for React Native … so `pod install` would break the Xcode project." No file changes.
3. `npx react-native run-ios` and `build-ios`: both build the app. The CLI sees the marker file and does not run `pod install`.
4. `npx react-native spm deinit`, then `pod install`: the CocoaPods build succeeds.
Not checked: Flow locally (my Flow binary is too old), `run-ios --force-pods`, and CLI 20.
Differential Revision: D129064536
Pull Request resolved: #59368
(cherry picked from commit b255245)spm deinit take an app back to CocoaPods1 parent 0ca7b7b commit bccb1df
13 files changed
Lines changed: 1297 additions & 307 deletions
File tree
- .github/workflows
- packages/react-native/scripts
- cocoapods
- spm
- __docs__
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
| 97 | + | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
| 108 | + | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
| 97 | + | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
319 | 337 | | |
320 | 338 | | |
321 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
0 commit comments