diff --git a/packages/community-cli-plugin/README.md b/packages/community-cli-plugin/README.md index 109193ff9c81..5e85b85737e1 100644 --- a/packages/community-cli-plugin/README.md +++ b/packages/community-cli-plugin/README.md @@ -112,7 +112,7 @@ npx @react-native-community/cli spm [action] [options] | `--yes` | Skip the dirty-pbxproj confirmation prompt. | | `--xcodeproj ` | **[add]** Path to the `.xcodeproj` to inject SPM packages into (disambiguates when several exist). | | `--productName ` | **[add]** App target to inject into (disambiguates when several exist). | -| `--deintegrate` | **[add]** Run `pod deintegrate` and strip React Native from the Podfile before injecting (CocoaPods → SwiftPM migration). | +| `--deintegrate` | **[add]** Remove the CocoaPods integration from the `.xcodeproj` before injecting (CocoaPods → SwiftPM migration). Uses `pod deintegrate` when CocoaPods is installed; CocoaPods is not required. The Podfile is kept. | | `--artifacts ` | **[advanced]** Local artifact root containing complete `debug/` and `release/` slots. | | `--download ` | **[advanced]** Artifact download policy: `auto` (default), `skip`, or `force`. | | `--skipCodegen` | **[advanced]** Skip the react-native codegen step. | diff --git a/packages/community-cli-plugin/src/commands/spm.js b/packages/community-cli-plugin/src/commands/spm.js index b0579adf3589..39a7139a2f0a 100644 --- a/packages/community-cli-plugin/src/commands/spm.js +++ b/packages/community-cli-plugin/src/commands/spm.js @@ -51,8 +51,10 @@ const spmCommand: Command = { { name: '--deintegrate', description: - '[add] Run `pod deintegrate` and strip React Native from the Podfile ' + - 'before injecting (CocoaPods → SwiftPM migration).', + '[add] Remove the CocoaPods integration from the .xcodeproj before ' + + 'injecting (CocoaPods → SwiftPM migration). Uses `pod deintegrate` ' + + 'when CocoaPods is installed; CocoaPods is not required. The Podfile ' + + 'is kept.', }, { name: '--artifacts ', diff --git a/packages/react-native/scripts/setup-apple-spm.js b/packages/react-native/scripts/setup-apple-spm.js index 98076c2c03d6..82cb89eb512d 100644 --- a/packages/react-native/scripts/setup-apple-spm.js +++ b/packages/react-native/scripts/setup-apple-spm.js @@ -29,8 +29,9 @@ * settings, the Sync build phase) into your * existing .xcodeproj, in place. Idempotent. * Default on first run. `--deintegrate` first - * runs `pod deintegrate` and keeps the Podfile - * (CocoaPods → SPM migration). + * removes the CocoaPods integration from the + * .xcodeproj and keeps the Podfile (CocoaPods → + * SPM migration). * update Re-run the pipeline and refresh the existing * injection. Default once a project is injected. * deinit The exact inverse of `add`: surgically remove @@ -56,8 +57,11 @@ * --yes Skip the dirty-pbxproj confirmation prompt. * [add] --xcodeproj Which .xcodeproj to inject into (when several). * [add] --product-name Which app target to inject into (when several). - * [add] --deintegrate Run `pod deintegrate` before injecting. The - * Podfile is kept. + * [add] --deintegrate Remove the CocoaPods integration from the + * .xcodeproj before injecting: `pod deintegrate` + * when CocoaPods is installed, otherwise the + * script edits the project itself. The Podfile + * is kept. * [advanced] --artifacts Local two-flavor artifact root; * must contain debug/ and release/ cache slots. * [advanced] --download Artifact policy (default: auto). @@ -126,6 +130,7 @@ const { refreshScaffoldedPlatformFloors, scaffoldAll, } = require('./spm/scaffold-package-swift'); +const {removeCocoaPodsIntegration} = require('./spm/spm-pbxproj'); const { CXX_API_DEFINES, RemoteVersionError, @@ -201,7 +206,7 @@ function parseArgs(argv /*: Array */) /*: SetupArgs */ { type: 'boolean', default: false, describe: - '[add] Run `pod deintegrate` before injecting (CocoaPods → SPM migration). The Podfile is kept.', + '[add] Remove the CocoaPods integration from the .xcodeproj before injecting (CocoaPods → SPM migration). Uses `pod deintegrate` when CocoaPods is installed; CocoaPods is not required. The Podfile is kept.', }) .option('artifacts', { type: 'string', @@ -733,15 +738,17 @@ function generateXcframeworksPackage( generatePackage(packageArgs); } -// True when the chosen pbxproj is still CocoaPods-integrated (its build configs -// layer a `Pods-*.xcconfig`) — the real blocker for SPM injection. +// True when a pbxproj is still CocoaPods-integrated (its build configs layer a +// `Pods-*.xcconfig`) — the real blocker for SPM injection. +function usesCocoaPods(pbxproj /*: string */) /*: boolean */ { + return /\bPods[-/][^\n]*\.xcconfig\b/.test(pbxproj); +} + function pbxprojUsesCocoaPods(xcodeprojPath /*: string */) /*: boolean */ { try { - const t = fs.readFileSync( - path.join(xcodeprojPath, 'project.pbxproj'), - 'utf8', + return usesCocoaPods( + fs.readFileSync(path.join(xcodeprojPath, 'project.pbxproj'), 'utf8'), ); - return /\bPods[-/][^\n]*\.xcconfig\b/.test(t); } catch { return false; } @@ -750,8 +757,10 @@ function pbxprojUsesCocoaPods(xcodeprojPath /*: string */) /*: boolean */ { function cocoaPodsIntegratedMessage(xcodeprojPath /*: string */) /*: string */ { return ( `${path.basename(xcodeprojPath)} is CocoaPods-integrated. To move it to ` + - 'SwiftPM, run `npx react-native spm add --deintegrate`. It runs ' + - '`pod deintegrate` and keeps the Podfile, so ' + + 'SwiftPM, run `npx react-native spm add --deintegrate`. It removes the ' + + 'CocoaPods integration from the project, with `pod deintegrate` when ' + + 'CocoaPods is installed; CocoaPods is not required. It keeps the ' + + 'Podfile, so ' + '`npx react-native spm deinit` and then `pod install` go back to ' + 'CocoaPods. Pods other than React Native are not installed while the app ' + 'uses SwiftPM, unless SwiftPM provides them.' @@ -797,18 +806,39 @@ function podfilePodNames(appRoot /*: string */) /*: Array */ { } // Run `pod deintegrate` and leave the Podfile as it is, so `spm deinit` and -// then `pod install` go back to CocoaPods. Requires CocoaPods on PATH -// (fail-loud otherwise). Does NOT touch the .xcworkspace. -function runDeintegrate(appRoot /*: string */) /*: void */ { +// then `pod install` go back to CocoaPods. Without CocoaPods on PATH (e.g. a +// fresh template app on a Mac that never installed it), strip the CocoaPods +// references from the pbxproj directly instead — all or nothing, so a project +// it cannot fully clean is left as it was. Does NOT touch the .xcworkspace. +function runDeintegrate( + appRoot /*: string */, + xcodeprojPath /*: string */, +) /*: void */ { try { execFileSync('pod', ['--version'], {stdio: 'ignore'}); } catch { - logError( - '`--deintegrate` needs CocoaPods (`pod`) on PATH. Remove the React ' + - 'Native integration from your project manually, then run `spm add`.', - ); - process.exitCode = 1; - throw new Error('pod not found'); + const projectName = path.basename(xcodeprojPath); + const pbxprojPath = path.join(xcodeprojPath, 'project.pbxproj'); + const original = fs.readFileSync(pbxprojPath, 'utf8'); + const deintegrated = removeCocoaPodsIntegration(original); + if (usesCocoaPods(deintegrated)) { + logError( + `CocoaPods is not installed, and ${projectName} has CocoaPods ` + + 'references this script cannot remove, so it was left unchanged. ' + + 'Install CocoaPods and run the same command again, or remove the ' + + 'remaining CocoaPods references from the project by hand.', + ); + process.exitCode = 1; + throw new Error('CocoaPods references remain'); + } + if (deintegrated !== original) { + fs.writeFileSync(pbxprojPath, deintegrated, 'utf8'); + log( + 'CocoaPods is not installed, so the CocoaPods references were ' + + `removed from ${projectName} directly.`, + ); + } + return; } log('Running `pod deintegrate`...'); execFileSync('pod', ['deintegrate'], {cwd: appRoot, stdio: 'inherit'}); @@ -907,7 +937,7 @@ async function setupXcodeproj( // No backup is made — git is the safety net. Refuse on a dirty/untracked // pbxproj unless --yes, so a bad inject is always `git checkout`-able. Asked - // before `pod deintegrate` edits the pbxproj, so "no" changes nothing. + // before `--deintegrate` edits the pbxproj, so "no" changes nothing. const clean = gitTrackedAndClean(appRoot, pbxprojPath); if (clean === false && !args.yes) { const proceed = await promptYesNo( @@ -928,7 +958,7 @@ async function setupXcodeproj( } if (args.deintegrate) { - runDeintegrate(appRoot); + runDeintegrate(appRoot, xcodeprojPath); // `pod deintegrate` strips the build integration but can leave an empty // `Pods` group in the navigator — remove it so the converted project is // visually clean. diff --git a/packages/react-native/scripts/spm/__docs__/README.md b/packages/react-native/scripts/spm/__docs__/README.md index 7bea063888b7..942530142fff 100644 --- a/packages/react-native/scripts/spm/__docs__/README.md +++ b/packages/react-native/scripts/spm/__docs__/README.md @@ -24,9 +24,12 @@ npx react-native spm # add on first run, update thereafter ``` On a CocoaPods app, this stops and changes nothing. To convert the app, run -`npx react-native spm add --deintegrate`. It runs `pod deintegrate` and keeps -the `Podfile`. It warns about pods that are not part of React Native, because -they are not installed while the app uses SwiftPM. +`npx react-native spm add --deintegrate`. It removes the CocoaPods integration +from the `.xcodeproj` and keeps the `Podfile`. CocoaPods does not need to be +installed: the command uses `pod deintegrate` when it is, and otherwise removes +the CocoaPods references from the `.xcodeproj` itself. It warns about pods that +are not part of React Native, because they are not installed while the app uses +SwiftPM. `pod install` on a converted app stops with an error. To go back to CocoaPods, run `npx react-native spm deinit`, then `pod install` in `ios/`. If your Podfile diff --git a/packages/react-native/scripts/spm/__docs__/spm-scripts.md b/packages/react-native/scripts/spm/__docs__/spm-scripts.md index eec6b2e703a1..8ae17f49776a 100644 --- a/packages/react-native/scripts/spm/__docs__/spm-scripts.md +++ b/packages/react-native/scripts/spm/__docs__/spm-scripts.md @@ -41,8 +41,12 @@ dependency changes. **On a fresh clone or CI checkout, run CocoaPods app, `spm add` and a plain `spm` stop before they change anything and point you at `--deintegrate`. `spm add --deintegrate`: -1. runs `pod deintegrate`. This removes CocoaPods integration from the - `.xcodeproj` (Pods references, `[CP]` build phases, xcconfig links). +1. removes the CocoaPods integration from the `.xcodeproj` (Pods references, + `[CP]` build phases, xcconfig links). It runs `pod deintegrate` when + CocoaPods is installed. Otherwise it removes the same references from the + `.xcodeproj` itself and leaves `Pods/`, `Podfile.lock` and the `.xcworkspace` + on disk. If some references would remain, it stops and changes nothing. + CocoaPods does not need to be installed. 2. keeps the `Podfile` as it is. 3. injects SwiftPM into the `.xcodeproj`. @@ -120,7 +124,7 @@ redirects into `ios/` and prints a banner. | Action | Description | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `add` | Inject SwiftPM packages (package refs, the base reference to `ReactNativeSPM/ReactNativeSPM.xcconfig`, the Sync build phase) into the existing `.xcodeproj`, in place. Idempotent. Default on first run. `--deintegrate` first runs `pod deintegrate` and keeps the Podfile. | +| `add` | Inject SwiftPM packages (package refs, the base reference to `ReactNativeSPM/ReactNativeSPM.xcconfig`, the Sync build phase) into the existing `.xcodeproj`, in place. Idempotent. Default on first run. `--deintegrate` first removes the CocoaPods integration from the `.xcodeproj` and keeps the Podfile. | | `update` | Re-run the pipeline and refresh the existing injection. Default once a project is injected. | | `deinit` | The inverse of `add`: surgically remove only what `add` injected (recorded in `.spm-injected.json`) and drop the marker. Leaves the Podfile alone; run `pod install` next to go back to CocoaPods. Git-recoverable; no prompt. Some edits it does not undo — see [Files the tool touches](#files-the-tool-touches). | | `scaffold` | Generate `Package.swift` into `node_modules//` for community RN libraries that ship only a podspec. | @@ -138,7 +142,7 @@ Flags below use the `react-native spm` (camelCase) form. | `--yes` | Skip the dirty-pbxproj confirmation prompt | | `--xcodeproj ` | [add, update, scaffold, deinit] Which `.xcodeproj` to inject into or remove from (when several exist) | | `--productName ` | [add, update, scaffold] Which app target to inject into (when several exist) | -| `--deintegrate` | [add] Run `pod deintegrate` before injecting. The Podfile is kept. Warns about pods that are not part of React Native; see [Keeping non-RN pods](#keeping-non-rn-pods) | +| `--deintegrate` | [add] Remove the CocoaPods integration from the `.xcodeproj` before injecting: `pod deintegrate` when CocoaPods is installed, otherwise the script edits the `.xcodeproj` itself. The Podfile is kept. Warns about pods that are not part of React Native; see [Keeping non-RN pods](#keeping-non-rn-pods) | | `--artifacts ` | [advanced] Local artifact root containing complete `debug/` and `release/` cache slots | | `--download ` | [advanced] Artifact download policy (default: auto) | | `--skipCodegen` | [advanced] Skip the codegen step | @@ -300,7 +304,7 @@ Paths are relative to the Xcode project directory (`ios/`) unless noted. | `ReactNativeSPM/Scripts/` | `add`, `update`, `scaffold` | Regenerated on each run and written when their content changes: `sync-autolinking.sh` and `embed-flavored-frameworks.sh`, the scripts the Sync and embed phases run. Plugin script phases keep their scripts in `project.pbxproj`. **Commit it.** When a script is missing, its phase fails the build with `error: is missing. Run 'npx react-native spm update' to generate it.` | Yes — both scripts are deleted, then each `ReactNativeSPM/` directory left empty | | `MyApp.xcodeproj/xcshareddata/xcschemes/*.xcscheme` | `add`, `update`, `scaffold` | The sync pre-action is added to the scheme that builds your target; a shared scheme is created if there is none. Commit this or teammates lose the pre-action. | Yes — a scheme `add` created is deleted only if it is still byte-identical to the generated one; otherwise only the pre-action is stripped | | `.gitignore` | `add` only | Created if absent, else appended: a `# SPM – auto-generated at build time` block adding `Package.resolved`, `build/generated/`, `build/xcframeworks/`, `.build/`. | Yes — only the lines `add` wrote, as recorded in the marker, and the file too if `add` created it and nothing else is left. A line you changed is kept, and `deinit` says so. A marker from an older version has no record, so `.gitignore` is left as it is | -| `Pods/`, `Pods-*.xcconfig`, `[CP]` phases | `add --deintegrate` | Removed by `pod deintegrate`. The `.xcworkspace` referencing them is left on disk. | **No** — run `pod install` to restore | +| `Pods/`, `Pods-*.xcconfig`, `[CP]` phases | `add --deintegrate` | Removed by `pod deintegrate`. Without CocoaPods installed, only the `.xcodeproj` references are removed; `Pods/` stays on disk. The `.xcworkspace` referencing them is left on disk. | **No** — run `pod install` to restore | The two pins are the `--version` pin (`artifactsVersionOverride`, see [Pinning the React Native version](#pinning-the-react-native-version)) and the @@ -727,7 +731,7 @@ across apps; refresh it with `react-native spm update --download force`. | ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `xcodebuild` fails: "Could not resolve package dependencies … `build/generated/autolinking` doesn't exist" | Fresh clone — run `npx react-native spm` once before building (see [Fresh clones & CI](#fresh-clones--ci)) | | Build fails: `error: …/ReactNativeSPM/Scripts/.sh is missing` | `ReactNativeSPM/` was not committed. Run `npx react-native spm update`, then commit `ReactNativeSPM/` | -| `spm add` fails: "CocoaPods-integrated project" | Re-run `spm add --deintegrate` (runs `pod deintegrate` and keeps the Podfile). Pods that are not part of React Native are not installed while the app uses SwiftPM (see [Keeping non-RN pods](#keeping-non-rn-pods)). | +| `spm add` fails: "CocoaPods-integrated project" | Re-run `spm add --deintegrate` (removes the CocoaPods integration from the `.xcodeproj` and keeps the Podfile). Pods that are not part of React Native are not installed while the app uses SwiftPM (see [Keeping non-RN pods](#keeping-non-rn-pods)). | | `pod install` fails: "This app uses Swift Package Manager for React Native" | The app was converted with `spm add`. To go back to CocoaPods, run `npx react-native spm deinit`, then `pod install`. | | `spm add` fails: "no .xcodeproj found" | Create an app first (`npx @react-native-community/cli init`) or make a project in Xcode, then `spm add`. | | `spm add` fails: "multiple .xcodeproj found" | Pass `--xcodeproj ` (and `--productName ` if multiple app targets). | diff --git a/packages/react-native/scripts/spm/__tests__/__fixtures__/cocoapods-app.pbxproj b/packages/react-native/scripts/spm/__tests__/__fixtures__/cocoapods-app.pbxproj new file mode 100644 index 000000000000..e3cd20e1f572 --- /dev/null +++ b/packages/react-native/scripts/spm/__tests__/__fixtures__/cocoapods-app.pbxproj @@ -0,0 +1,742 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 00E356F31AD99517003FC87E /* HelloWorldTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* HelloWorldTests.m */; }; + 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; + 6EA01F72FAC10D00AECACF94 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 0EC7AB76F90EED035707BA4E /* PrivacyInfo.xcprivacy */; }; + 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; + C5E681697D864CB241D83EFA /* libPods-HelloWorld-HelloWorldTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A8E5ECDA77F0C61C263AE4C /* libPods-HelloWorld-HelloWorldTests.a */; }; + CDA0ED1A2D0B2D810079F561 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA0ED192D0B2D810079F561 /* AppDelegate.swift */; }; + CDA0ED1B2D0B2D810079F562 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA0ED1C2D0B2D810079F562 /* SceneDelegate.swift */; }; + F139D3B2B0DB3E81C6EC8497 /* libPods-HelloWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E4454510AD252A40B7E239F /* libPods-HelloWorld.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 13B07F861A680F5B00A75B9A; + remoteInfo = HelloWorld; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 00E356EE1AD99517003FC87E /* HelloWorldTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HelloWorldTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 00E356F21AD99517003FC87E /* HelloWorldTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HelloWorldTests.m; sourceTree = ""; }; + 0EC7AB76F90EED035707BA4E /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = HelloWorld/PrivacyInfo.xcprivacy; sourceTree = ""; }; + 13B07F961A680F5B00A75B9A /* HelloWorld.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = HelloWorld/Images.xcassets; sourceTree = ""; }; + 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = HelloWorld/Info.plist; sourceTree = ""; }; + 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = HelloWorld/PrivacyInfo.xcprivacy; sourceTree = ""; }; + 3B4392A12AC88292D35C810B /* Pods-HelloWorld.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld.debug.xcconfig"; path = "Target Support Files/Pods-HelloWorld/Pods-HelloWorld.debug.xcconfig"; sourceTree = ""; }; + 3E4454510AD252A40B7E239F /* libPods-HelloWorld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorld.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 5709B34CF0A7D63546082F79 /* Pods-HelloWorld.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld/Pods-HelloWorld.release.xcconfig"; sourceTree = ""; }; + 5B7EB9410499542E8C5724F5 /* Pods-HelloWorld-HelloWorldTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld-HelloWorldTests.debug.xcconfig"; path = "Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests.debug.xcconfig"; sourceTree = ""; }; + 7A8E5ECDA77F0C61C263AE4C /* libPods-HelloWorld-HelloWorldTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorld-HelloWorldTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = HelloWorld/LaunchScreen.storyboard; sourceTree = ""; }; + 89C6BE57DB24E9ADA2F236DE /* Pods-HelloWorld-HelloWorldTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld-HelloWorldTests.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests.release.xcconfig"; sourceTree = ""; }; + CDA0ED192D0B2D810079F561 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = HelloWorld/AppDelegate.swift; sourceTree = ""; }; + CDA0ED1C2D0B2D810079F562 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SceneDelegate.swift; path = HelloWorld/SceneDelegate.swift; sourceTree = ""; }; + ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 00E356EB1AD99517003FC87E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C5E681697D864CB241D83EFA /* libPods-HelloWorld-HelloWorldTests.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F139D3B2B0DB3E81C6EC8497 /* libPods-HelloWorld.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 00E356EF1AD99517003FC87E /* HelloWorldTests */ = { + isa = PBXGroup; + children = ( + 00E356F21AD99517003FC87E /* HelloWorldTests.m */, + 00E356F01AD99517003FC87E /* Supporting Files */, + ); + path = HelloWorldTests; + sourceTree = ""; + }; + 00E356F01AD99517003FC87E /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 00E356F11AD99517003FC87E /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 13B07FAE1A68108700A75B9A /* HelloWorld */ = { + isa = PBXGroup; + children = ( + 13B07FB51A68108700A75B9A /* Images.xcassets */, + 13B07FB61A68108700A75B9A /* Info.plist */, + 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, + 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */, + 0EC7AB76F90EED035707BA4E /* PrivacyInfo.xcprivacy */, + CDA0ED192D0B2D810079F561 /* AppDelegate.swift */, + CDA0ED1C2D0B2D810079F562 /* SceneDelegate.swift */, + ); + name = HelloWorld; + sourceTree = ""; + }; + 2D16E6871FA4F8E400B85C8A /* Frameworks */ = { + isa = PBXGroup; + children = ( + ED297162215061F000B7C4FE /* JavaScriptCore.framework */, + 3E4454510AD252A40B7E239F /* libPods-HelloWorld.a */, + 7A8E5ECDA77F0C61C263AE4C /* libPods-HelloWorld-HelloWorldTests.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 832341AE1AAA6A7D00B99B32 /* Libraries */ = { + isa = PBXGroup; + children = ( + ); + name = Libraries; + sourceTree = ""; + }; + 83CBB9F61A601CBA00E9B192 = { + isa = PBXGroup; + children = ( + 13B07FAE1A68108700A75B9A /* HelloWorld */, + 832341AE1AAA6A7D00B99B32 /* Libraries */, + 00E356EF1AD99517003FC87E /* HelloWorldTests */, + 83CBBA001A601CBA00E9B192 /* Products */, + 2D16E6871FA4F8E400B85C8A /* Frameworks */, + BBD78D7AC51CEA395F1C20DB /* Pods */, + ); + indentWidth = 2; + sourceTree = ""; + tabWidth = 2; + usesTabs = 0; + }; + 83CBBA001A601CBA00E9B192 /* Products */ = { + isa = PBXGroup; + children = ( + 13B07F961A680F5B00A75B9A /* HelloWorld.app */, + 00E356EE1AD99517003FC87E /* HelloWorldTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + BBD78D7AC51CEA395F1C20DB /* Pods */ = { + isa = PBXGroup; + children = ( + 3B4392A12AC88292D35C810B /* Pods-HelloWorld.debug.xcconfig */, + 5709B34CF0A7D63546082F79 /* Pods-HelloWorld.release.xcconfig */, + 5B7EB9410499542E8C5724F5 /* Pods-HelloWorld-HelloWorldTests.debug.xcconfig */, + 89C6BE57DB24E9ADA2F236DE /* Pods-HelloWorld-HelloWorldTests.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 00E356ED1AD99517003FC87E /* HelloWorldTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "HelloWorldTests" */; + buildPhases = ( + A55EABD7B0C7F3A422A6CC61 /* [CP] Check Pods Manifest.lock */, + 00E356EA1AD99517003FC87E /* Sources */, + 00E356EB1AD99517003FC87E /* Frameworks */, + 00E356EC1AD99517003FC87E /* Resources */, + F6A41C54EA430FDDC6A6ED99 /* [CP] Copy Pods Resources */, + A44ED3CC3037C88F69E3AF15 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 00E356F51AD99517003FC87E /* PBXTargetDependency */, + ); + name = HelloWorldTests; + productName = HelloWorldTests; + productReference = 00E356EE1AD99517003FC87E /* HelloWorldTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 13B07F861A680F5B00A75B9A /* HelloWorld */ = { + isa = PBXNativeTarget; + buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "HelloWorld" */; + buildPhases = ( + C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */, + 13B07F871A680F5B00A75B9A /* Sources */, + 13B07F8C1A680F5B00A75B9A /* Frameworks */, + 13B07F8E1A680F5B00A75B9A /* Resources */, + 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, + E235C05ADACE081382539298 /* [CP] Copy Pods Resources */, + D32CB2BA406E97DB62F51C6B /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = HelloWorld; + productName = HelloWorld; + productReference = 13B07F961A680F5B00A75B9A /* HelloWorld.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 83CBB9F71A601CBA00E9B192 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1210; + TargetAttributes = { + 00E356ED1AD99517003FC87E = { + CreatedOnToolsVersion = 6.2; + TestTargetID = 13B07F861A680F5B00A75B9A; + }; + 13B07F861A680F5B00A75B9A = { + LastSwiftMigration = 1610; + }; + }; + }; + buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "HelloWorld" */; + compatibilityVersion = "Xcode 12.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 83CBB9F61A601CBA00E9B192; + productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 13B07F861A680F5B00A75B9A /* HelloWorld */, + 00E356ED1AD99517003FC87E /* HelloWorldTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 00E356EC1AD99517003FC87E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 13B07F8E1A680F5B00A75B9A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, + 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, + 6EA01F72FAC10D00AECACF94 /* PrivacyInfo.xcprivacy in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/.xcode.env.local", + "$(SRCROOT)/.xcode.env", + "$(SRCROOT)/../.react-native.config", + ); + name = "Bundle React Native code and images"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "set -e\n\nexport CONFIG_JSON=$(sed -e \"s|HELLOWORLD_PATH|$(realpath \"${SRCROOT}/../\")|g\" -e \"s|REACT_NATIVE_PATH|$(realpath \"${REACT_NATIVE_PATH}\")|g\" \"${SRCROOT}/../.react-native.config\")\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; + }; + A44ED3CC3037C88F69E3AF15 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + A55EABD7B0C7F3A422A6CC61 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-HelloWorld-HelloWorldTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-HelloWorld-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + D32CB2BA406E97DB62F51C6B /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-HelloWorld/Pods-HelloWorld-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-HelloWorld/Pods-HelloWorld-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-HelloWorld/Pods-HelloWorld-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + E235C05ADACE081382539298 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-HelloWorld/Pods-HelloWorld-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-HelloWorld/Pods-HelloWorld-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-HelloWorld/Pods-HelloWorld-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + F6A41C54EA430FDDC6A6ED99 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 00E356EA1AD99517003FC87E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 00E356F31AD99517003FC87E /* HelloWorldTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 13B07F871A680F5B00A75B9A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CDA0ED1A2D0B2D810079F561 /* AppDelegate.swift in Sources */, + CDA0ED1B2D0B2D810079F562 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 13B07F861A680F5B00A75B9A /* HelloWorld */; + targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 00E356F61AD99517003FC87E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5B7EB9410499542E8C5724F5 /* Pods-HelloWorld-HelloWorldTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = HelloWorldTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.1; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + OTHER_LDFLAGS = ( + "-ObjC", + "-lc++", + "$(inherited)", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + REACT_NATIVE_PATH = "${PODS_ROOT}/../../../react-native"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HelloWorld.app/HelloWorld"; + }; + name = Debug; + }; + 00E356F71AD99517003FC87E /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 89C6BE57DB24E9ADA2F236DE /* Pods-HelloWorld-HelloWorldTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + COPY_PHASE_STRIP = NO; + INFOPLIST_FILE = HelloWorldTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.1; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + OTHER_LDFLAGS = ( + "-ObjC", + "-lc++", + "$(inherited)", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + REACT_NATIVE_PATH = "${PODS_ROOT}/../../../react-native"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HelloWorld.app/HelloWorld"; + }; + name = Release; + }; + 13B07F941A680F5B00A75B9A /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3B4392A12AC88292D35C810B /* Pods-HelloWorld.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = 1; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = HelloWorld/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ( + "$(inherited)", + "-ObjC", + "-lc++", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = HelloWorld; + REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../packages/react-native"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 13B07F951A680F5B00A75B9A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5709B34CF0A7D63546082F79 /* Pods-HelloWorld.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = 1; + INFOPLIST_FILE = HelloWorld/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ( + "$(inherited)", + "-ObjC", + "-lc++", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = HelloWorld; + REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../packages/react-native"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; + 83CBBA201A601CBA00E9B192 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "c++20"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios", + "${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx", + "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios", + ); + IPHONEOS_DEPLOYMENT_TARGET = 15.1; + LD_RUNPATH_SEARCH_PATHS = ( + /usr/lib/swift, + "$(inherited)", + ); + LIBRARY_SEARCH_PATHS = ( + "\"$(SDKROOT)/usr/lib/swift\"", + "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", + "\"$(inherited)\"", + ); + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = ( + "$(inherited)", + "-DRCT_REMOVE_LEGACY_ARCH=1", + ); + OTHER_CPLUSPLUSFLAGS = ( + "$(OTHER_CFLAGS)", + "-DFOLLY_NO_CONFIG", + "-DFOLLY_MOBILE=1", + "-DFOLLY_USE_LIBCPP=1", + "-DFOLLY_CFG_NO_COROUTINES=1", + "-DFOLLY_HAVE_CLOCK_GETTIME=1", + "-DRCT_REMOVE_LEGACY_ARCH=1", + ); + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); + PODFILE_DIR = "$(SRCROOT)"; + REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../packages/react-native"; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG"; + USE_HERMES = true; + }; + name = Debug; + }; + 83CBBA211A601CBA00E9B192 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "c++20"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios", + "${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx", + "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios", + ); + IPHONEOS_DEPLOYMENT_TARGET = 15.1; + LD_RUNPATH_SEARCH_PATHS = ( + /usr/lib/swift, + "$(inherited)", + ); + LIBRARY_SEARCH_PATHS = ( + "\"$(SDKROOT)/usr/lib/swift\"", + "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", + "\"$(inherited)\"", + ); + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_CFLAGS = ( + "$(inherited)", + "-DRCT_REMOVE_LEGACY_ARCH=1", + ); + OTHER_CPLUSPLUSFLAGS = ( + "$(OTHER_CFLAGS)", + "-DFOLLY_NO_CONFIG", + "-DFOLLY_MOBILE=1", + "-DFOLLY_USE_LIBCPP=1", + "-DFOLLY_CFG_NO_COROUTINES=1", + "-DFOLLY_HAVE_CLOCK_GETTIME=1", + "-DRCT_REMOVE_LEGACY_ARCH=1", + ); + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); + PODFILE_DIR = "$(SRCROOT)"; + REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../packages/react-native"; + SDKROOT = iphoneos; + USE_HERMES = true; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "HelloWorldTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 00E356F61AD99517003FC87E /* Debug */, + 00E356F71AD99517003FC87E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "HelloWorld" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 13B07F941A680F5B00A75B9A /* Debug */, + 13B07F951A680F5B00A75B9A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "HelloWorld" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 83CBBA201A601CBA00E9B192 /* Debug */, + 83CBBA211A601CBA00E9B192 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; +} diff --git a/packages/react-native/scripts/spm/__tests__/setup-apple-spm-test.js b/packages/react-native/scripts/spm/__tests__/setup-apple-spm-test.js index 0a916ba63ee9..e19da7617a8d 100644 --- a/packages/react-native/scripts/spm/__tests__/setup-apple-spm-test.js +++ b/packages/react-native/scripts/spm/__tests__/setup-apple-spm-test.js @@ -14,9 +14,11 @@ // and the autolinking config command (spawnSync → npx) fails fast instead of // reaching the network. A test that sets mockAutolinkingSourceDir lets the // config command succeed instead, so `main` gets far enough to write -// build/generated/ — what "refuses before any change" has to rule out. git and +// build/generated/ — what "refuses before any change" has to rule out. A test +// that sets mockPodMissing runs as if CocoaPods were not installed. git and // everything else run for real. const mockPodCalls = []; +let mockPodMissing = false; let mockAutolinkingSourceDir = null; jest.mock('node:child_process', () => { const actual = jest.requireActual('node:child_process'); @@ -25,6 +27,11 @@ jest.mock('node:child_process', () => { execFileSync: (command, args, options) => { if (command === 'pod') { mockPodCalls.push(args); + if (mockPodMissing) { + throw Object.assign(new Error('spawnSync pod ENOENT'), { + code: 'ENOENT', + }); + } return ''; } return actual.execFileSync(command, args, options); @@ -812,6 +819,7 @@ describe('CocoaPods conversion', () => { afterEach(() => { jest.restoreAllMocks(); process.exitCode = undefined; + mockPodMissing = false; mockAutolinkingSourceDir = null; mockInjectorCalls = null; mockInjectorRefusal = null; @@ -876,8 +884,11 @@ describe('CocoaPods conversion', () => { describe('add --deintegrate', () => { it('runs `pod deintegrate` and leaves the Podfile byte-identical, with no Podfile.bak', () => { fs.writeFileSync(podfilePath, STOCK_PODFILE); + const xcodeproj = mkXcodeproj(appRoot, 'MyApp.xcodeproj', { + cocoapods: true, + }); - runDeintegrate(appRoot); + runDeintegrate(appRoot, xcodeproj); expect(mockPodCalls).toContainEqual(['deintegrate']); expect(fs.readFileSync(podfilePath, 'utf8')).toBe(STOCK_PODFILE); @@ -934,6 +945,114 @@ describe('CocoaPods conversion', () => { expectCocoaPodsAdvice(); }); + describe('without CocoaPods installed', () => { + const COCOAPODS_PBXPROJ = fs.readFileSync( + path.join(__dirname, '__fixtures__', 'cocoapods-app.pbxproj'), + 'utf8', + ); + + beforeEach(() => { + mockPodMissing = true; + }); + + function mkCocoaPodsXcodeproj(pbxproj = COCOAPODS_PBXPROJ) { + const xcodeproj = path.join(appRoot, 'MyApp.xcodeproj'); + fs.mkdirSync(xcodeproj); + fs.writeFileSync(path.join(xcodeproj, 'project.pbxproj'), pbxproj); + return xcodeproj; + } + + it('removes the CocoaPods references from the project itself and leaves every CocoaPods file on disk', () => { + const xcodeproj = mkCocoaPodsXcodeproj(); + fs.writeFileSync(podfilePath, STOCK_PODFILE); + fs.writeFileSync(path.join(appRoot, 'Podfile.lock'), 'PODS:\n'); + fs.mkdirSync(path.join(appRoot, 'Pods')); + fs.mkdirSync(path.join(appRoot, 'MyApp.xcworkspace')); + + runDeintegrate(appRoot, xcodeproj); + + const pbxproj = fs.readFileSync( + path.join(xcodeproj, 'project.pbxproj'), + 'utf8', + ); + expect(pbxproj).not.toContain('[CP]'); + expect(pbxproj).not.toMatch(/\bPods[-/][^\n]*\.xcconfig\b/); + expect(output(logSpy)).toMatch(/CocoaPods is not installed/); + expect(mockPodCalls).not.toContainEqual(['deintegrate']); + expect(fs.readFileSync(podfilePath, 'utf8')).toBe(STOCK_PODFILE); + expect(fs.existsSync(path.join(appRoot, 'Podfile.lock'))).toBe(true); + expect(fs.existsSync(path.join(appRoot, 'Pods'))).toBe(true); + expect(fs.existsSync(path.join(appRoot, 'MyApp.xcworkspace'))).toBe( + true, + ); + }); + + it('converts a CocoaPods-integrated project', async () => { + mkCocoaPodsXcodeproj(); + fs.writeFileSync(podfilePath, STOCK_PODFILE); + + await runAdd('--deintegrate'); + + expect(process.exitCode).toBeUndefined(); + expect(mockInjectorCalls).toHaveLength(1); + expect(mockPodCalls).not.toContainEqual(['deintegrate']); + expect(fs.readFileSync(podfilePath, 'utf8')).toBe(STOCK_PODFILE); + }); + + it('changes nothing and says how to finish by hand when references it does not know remain', async () => { + // CocoaPods 1.16 points a build configuration at its xcconfig through a + // synchronized folder (Xcode 16) instead of a file reference. + const pbxproj = COCOAPODS_PBXPROJ.replace( + '\t\t\tbaseConfigurationReference = 3B4392A12AC88292D35C810B /* Pods-HelloWorld.debug.xcconfig */;\n', + '\t\t\tbaseConfigurationReferenceAnchor = DD0000000000000000000001 /* Pods */;\n' + + '\t\t\tbaseConfigurationReferenceRelativePath = "Target Support Files/Pods-HelloWorld/Pods-HelloWorld.debug.xcconfig";\n', + ); + const xcodeproj = mkCocoaPodsXcodeproj(pbxproj); + fs.writeFileSync(podfilePath, STOCK_PODFILE); + + await runAdd('--deintegrate'); + + expect(process.exitCode).toBe(1); + expect( + fs.readFileSync(path.join(xcodeproj, 'project.pbxproj'), 'utf8'), + ).toBe(pbxproj); + expect(errors()).toMatch(/[Ii]nstall CocoaPods/); + expect(errors()).toMatch(/by hand/); + expect(errors()).not.toContain('--deintegrate'); + expect(output(logSpy)).not.toMatch(/CocoaPods is not installed/); + expect(mockInjectorCalls).toEqual([]); + }); + + it('changes nothing and says nothing about CocoaPods on a project without it', () => { + const xcodeproj = mkXcodeproj(appRoot, 'MyApp.xcodeproj'); + const pbxprojPath = path.join(xcodeproj, 'project.pbxproj'); + const pbxproj = fs.readFileSync(pbxprojPath, 'utf8'); + + runDeintegrate(appRoot, xcodeproj); + + expect(fs.readFileSync(pbxprojPath, 'utf8')).toBe(pbxproj); + expect(output(logSpy)).not.toMatch(/CocoaPods is not installed/); + expect(process.exitCode).toBeUndefined(); + }); + }); + + it('leaves the project to `pod deintegrate` when CocoaPods is installed', () => { + const xcodeproj = path.join(appRoot, 'MyApp.xcodeproj'); + const pbxprojPath = path.join(xcodeproj, 'project.pbxproj'); + const pbxproj = fs.readFileSync( + path.join(__dirname, '__fixtures__', 'cocoapods-app.pbxproj'), + 'utf8', + ); + fs.mkdirSync(xcodeproj); + fs.writeFileSync(pbxprojPath, pbxproj); + + runDeintegrate(appRoot, xcodeproj); + + expect(mockPodCalls).toContainEqual(['deintegrate']); + expect(fs.readFileSync(pbxprojPath, 'utf8')).toBe(pbxproj); + expect(output(logSpy)).not.toMatch(/CocoaPods is not installed/); + }); + describe('on a project with uncommitted changes', () => { let isTTY; let question; diff --git a/packages/react-native/scripts/spm/__tests__/spm-pbxproj-test.js b/packages/react-native/scripts/spm/__tests__/spm-pbxproj-test.js index 16db46f653ab..3666df1eac79 100644 --- a/packages/react-native/scripts/spm/__tests__/spm-pbxproj-test.js +++ b/packages/react-native/scripts/spm/__tests__/spm-pbxproj-test.js @@ -25,6 +25,7 @@ const { quoteIfNeeded, removeArrayMembersByUuid, removeArrayStringValues, + removeCocoaPodsIntegration, removeDanglingJavaScriptCoreRef, removeEmptyPodsGroup, removeField, @@ -742,3 +743,170 @@ describe('removeDanglingJavaScriptCoreRef', () => { expect(twice).toBe(once); }); }); + +describe('removeCocoaPodsIntegration', () => { + // private/helloworld's project after `pod install`: two targets, six [CP] + // phases, two libPods archives and four Pods xcconfigs. + const COCOAPODS_PBXPROJ = fs.readFileSync( + path.join(__dirname, '__fixtures__', 'cocoapods-app.pbxproj'), + 'utf8', + ); + const COCOAPODS_UUIDS = [ + // [CP] shell script phases + 'A55EABD7B0C7F3A422A6CC61', + 'F6A41C54EA430FDDC6A6ED99', + 'A44ED3CC3037C88F69E3AF15', + 'C38B50BA6285516D6DCD4F65', + 'E235C05ADACE081382539298', + 'D32CB2BA406E97DB62F51C6B', + // libPods build files and file references + 'C5E681697D864CB241D83EFA', + 'F139D3B2B0DB3E81C6EC8497', + '7A8E5ECDA77F0C61C263AE4C', + '3E4454510AD252A40B7E239F', + // Pods xcconfig file references + '3B4392A12AC88292D35C810B', + '5709B34CF0A7D63546082F79', + '5B7EB9410499542E8C5724F5', + '89C6BE57DB24E9ADA2F236DE', + // Pods group + 'BBD78D7AC51CEA395F1C20DB', + ]; + + // The input minus every line that names one of `uuids`, and minus the body + // of every multi-line object those lines open. + function withoutLinesNaming(text, uuids) { + const kept = []; + let inRemovedObject = false; + for (const line of text.split('\n')) { + if (inRemovedObject) { + inRemovedObject = line !== '\t\t};'; + } else if (uuids.some(uuid => line.includes(uuid))) { + inRemovedObject = line.endsWith('= {'); + } else { + kept.push(line); + } + } + return kept.join('\n'); + } + + let deintegrated; + beforeAll(() => { + deintegrated = removeCocoaPodsIntegration(COCOAPODS_PBXPROJ); + }); + + it('removes the CocoaPods build integration', () => { + expect(deintegrated).not.toContain('[CP]'); + expect(deintegrated).not.toContain('libPods'); + expect(deintegrated).not.toContain('Pods-'); + expect(deintegrated).not.toContain('/* Pods */'); + expect(deintegrated).not.toContain('baseConfigurationReference'); + expect(deintegrated).not.toMatch(/\bPods[-/][^\n]*\.xcconfig\b/); + }); + + it('keeps the other build phases of both targets', () => { + const phases = targetUuid => { + const target = findObjectByUuid(deintegrated, targetUuid); + return findField(deintegrated, target, 'buildPhases').value; + }; + expect(phases('00E356ED1AD99517003FC87E')).toBe( + [ + '(', + '\t\t\t\t00E356EA1AD99517003FC87E /* Sources */,', + '\t\t\t\t00E356EB1AD99517003FC87E /* Frameworks */,', + '\t\t\t\t00E356EC1AD99517003FC87E /* Resources */,', + '\t\t\t)', + ].join('\n'), + ); + expect(phases('13B07F861A680F5B00A75B9A')).toBe( + [ + '(', + '\t\t\t\t13B07F871A680F5B00A75B9A /* Sources */,', + '\t\t\t\t13B07F8C1A680F5B00A75B9A /* Frameworks */,', + '\t\t\t\t13B07F8E1A680F5B00A75B9A /* Resources */,', + '\t\t\t\t00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,', + '\t\t\t)', + ].join('\n'), + ); + }); + + it('removes only the CocoaPods objects and the lines that reference them', () => { + expect(deintegrated).toBe( + withoutLinesNaming(COCOAPODS_PBXPROJ, COCOAPODS_UUIDS), + ); + }); + + it('is idempotent', () => { + expect(removeCocoaPodsIntegration(deintegrated)).toBe(deintegrated); + }); + + it('returns a project without CocoaPods unchanged', () => { + expect(removeCocoaPodsIntegration(PLAIN_PBXPROJ)).toBe(PLAIN_PBXPROJ); + }); + + it('removes [CP-User] phases and the unprefixed phase names of old CocoaPods versions', () => { + const variant = COCOAPODS_PBXPROJ.replaceAll( + '[CP] Check Pods Manifest.lock', + 'Check Pods Manifest.lock', + ).replaceAll( + '[CP] Embed Pods Frameworks', + '[CP-User] Embed Pods Frameworks', + ); + + expect(removeCocoaPodsIntegration(variant)).toBe(deintegrated); + }); + + it('removes Pods frameworks linked under use_frameworks!', () => { + const variant = COCOAPODS_PBXPROJ.replaceAll( + 'libPods-HelloWorld.a', + 'Pods_HelloWorld.framework', + ); + + expect(removeCocoaPodsIntegration(variant)).toBe(deintegrated); + }); + + it('keeps a [CP]-looking name on an object that is not a shell script phase', () => { + const variant = COCOAPODS_PBXPROJ.replace( + 'name = Libraries;', + 'name = "[CP] Libraries";', + ); + + expect(removeCocoaPodsIntegration(variant)).toContain( + 'name = "[CP] Libraries";', + ); + }); + + it("keeps the app's own xcconfigs", () => { + const fileRef = (uuid, file) => + `\t\t${uuid} /* ${file} */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ${file}; sourceTree = ""; };`; + const configRef = fileRef('CC0000000000000000000001', 'Config.xcconfig'); + const spmRef = fileRef( + 'CC0000000000000000000002', + 'ReactNativeSPM.xcconfig', + ); + const variant = COCOAPODS_PBXPROJ.replace( + '/* End PBXFileReference section */', + `${configRef}\n${spmRef}\n/* End PBXFileReference section */`, + ) + .replace( + '5B7EB9410499542E8C5724F5 /* Pods-HelloWorld-HelloWorldTests.debug.xcconfig */;', + 'CC0000000000000000000001 /* Config.xcconfig */;', + ) + .replace( + '3B4392A12AC88292D35C810B /* Pods-HelloWorld.debug.xcconfig */;', + 'CC0000000000000000000002 /* ReactNativeSPM.xcconfig */;', + ); + + const result = removeCocoaPodsIntegration(variant); + + expect(result).toContain(configRef); + expect(result).toContain(spmRef); + expect(result).toContain( + 'baseConfigurationReference = CC0000000000000000000001 /* Config.xcconfig */;', + ); + expect(result).toContain( + 'baseConfigurationReference = CC0000000000000000000002 /* ReactNativeSPM.xcconfig */;', + ); + expect(result).not.toMatch(/\bPods[-/][^\n]*\.xcconfig\b/); + }); +}); diff --git a/packages/react-native/scripts/spm/spm-pbxproj.js b/packages/react-native/scripts/spm/spm-pbxproj.js index 8b7a37baf7cb..bddb29964fb2 100644 --- a/packages/react-native/scripts/spm/spm-pbxproj.js +++ b/packages/react-native/scripts/spm/spm-pbxproj.js @@ -723,6 +723,92 @@ function removeEmptyPodsGroup(text /*: string */) /*: string */ { return removeObjectByUuid(removeArrayMembersByUuid(text, [uuid]), uuid); } +/** + * The value of a top-level `key = value;` field, unquoted and without a + * trailing `/* comment *​/`. Unlike findField it also reads the one-line + * objects (PBXFileReference, PBXBuildFile) that Xcode writes. + */ +function fieldValue( + text /*: string */, + obj /*: BodyRange */, + key /*: string */, +) /*: ?string */ { + const m = new RegExp( + `(?:^|;)\\s*${escapeRegExp(key)} = ("(?:[^"\\\\]|\\\\.)*"|[^;]*?)(?: \\/\\*.*?\\*\\/)?;`, + ).exec(text.slice(obj.bodyOpen + 1, obj.bodyClose)); + return m == null ? null : m[1].replace(/^"(.*)"$/s, '$1'); +} + +// The names Pod::Deintegrator (`pod deintegrate`) matches. +const COCOAPODS_SCRIPT_PHASE = + /^(?:\[CP(?:-User)?\] .*|Check Pods Manifest\.lock|Copy Pods Resources|Embed Pods Frameworks|Copy Pods Frameworks)$/; +const COCOAPODS_LIBRARY = /^(?:libPods.*\.a|Pods.*\.framework)$/i; +// Mirrors `pod deintegrate`, so it also matches an app's own PodsShared.xcconfig. +const COCOAPODS_XCCONFIG = /^Pods.*\.xcconfig$/i; + +/** + * Remove what `pod install` adds to an app's pbxproj — the `[CP]` script + * phases, the linked Pods library, the Pods xcconfigs layered under each build + * configuration, and then the emptied `Pods` group — for apps converted + * without CocoaPods installed. Every other byte is left as it was. + */ +function removeCocoaPodsIntegration(text /*: string */) /*: string */ { + const scriptPhases = []; + forEachObjectInSection(text, 'PBXShellScriptBuildPhase', obj => { + const name = fieldValue(text, obj, 'name'); + if (name != null && COCOAPODS_SCRIPT_PHASE.test(name)) { + scriptPhases.push(obj.uuid); + } + }); + + const libraries = new Set /*:: */(); + const xcconfigs = new Set /*:: */(); + forEachObjectInSection(text, 'PBXFileReference', obj => { + const fileNames = ['name', 'path'] + .map(key => fieldValue(text, obj, key)) + .filter(Boolean) + .map(value => value.slice(value.lastIndexOf('/') + 1)); + if (fileNames.some(fileName => COCOAPODS_LIBRARY.test(fileName))) { + libraries.add(obj.uuid); + } else if (fileNames.some(fileName => COCOAPODS_XCCONFIG.test(fileName))) { + xcconfigs.add(obj.uuid); + } + }); + + const libraryBuildFiles = []; + forEachObjectInSection(text, 'PBXBuildFile', obj => { + if (libraries.has(fieldValue(text, obj, 'fileRef') ?? '')) { + libraryBuildFiles.push(obj.uuid); + } + }); + + const xcconfigUsers = []; + forEachObjectInSection(text, 'XCBuildConfiguration', obj => { + const base = fieldValue(text, obj, 'baseConfigurationReference'); + if (xcconfigs.has(base ?? '')) { + xcconfigUsers.push(obj); + } + }); + + // Last to first, so the ranges found above still hold for the earlier ones. + let out = text; + for (const obj of xcconfigUsers.reverse()) { + out = removeField(out, obj, 'baseConfigurationReference'); + } + // Objects before member lines: a one-line object whose fields hold a comma + // would otherwise read as a member line. + const removed = [ + ...scriptPhases, + ...libraryBuildFiles, + ...libraries, + ...xcconfigs, + ]; + for (const uuid of removed) { + out = removeObjectByUuid(out, uuid); + } + return removeEmptyPodsGroup(removeArrayMembersByUuid(out, removed)); +} + /** * Remove the dangling `JavaScriptCore.framework` PBXFileReference the * community template has carried since RN 0.60 (an SDK framework reference @@ -800,5 +886,6 @@ module.exports = { removeField, removeArrayStringValues, removeEmptyPodsGroup, + removeCocoaPodsIntegration, removeDanglingJavaScriptCoreRef, }; diff --git a/packages/react-native/scripts/spm/spm-types.js b/packages/react-native/scripts/spm/spm-types.js index c06f2c18b679..aa58b118bb07 100644 --- a/packages/react-native/scripts/spm/spm-types.js +++ b/packages/react-native/scripts/spm/spm-types.js @@ -26,7 +26,8 @@ export type SetupArgs = { // `add` target selection: which app target (when several) and which project. productName: string | null, xcodeprojPath: string | null, - // `add`: run `pod deintegrate` before injecting. The Podfile is kept. + // `add`: remove the CocoaPods integration before injecting, with + // `pod deintegrate` when CocoaPods is installed. The Podfile is kept. deintegrate: boolean, // Skip the single remaining confirmation (the add/update dirty-pbxproj // warning). Non-TTY auto-proceeds regardless (git is the safety net).