Target Branch
0.87
Link to commit or PR to be picked
react/react-native@1cdf784 (PR react/react-native#57576)
Description
This is a hotfix for a breaking regression introduced by the prebuilt/SwiftPM stack that is being picked into 0.87 (see pick request #1344 and PR react/react-native#57578).
Symptom: any library using spm_dependency breaks the build in prebuilt mode. pod install succeeds, but xcodebuild cannot load the generated Pods project:
-[XCRemoteSwiftPackageReference _setSavedArchiveVersion:]: unrecognized selector sent to instance
Failed to load container at path: .../Pods/Pods.xcodeproj — "The project 'Pods' is damaged and cannot be opened."
This was caught by the first nightly containing the SwiftPM stack, which broke the react-native-enriched-markdown job in react-native-community/nightly-tests.
Root cause: spm_dependency injects package-reference objects from a post_install hook via project.new(...). CocoaPods' Pod::Project uses a deterministic UUID counter and skips collision checks (it assumes a freshly generated project). When the counters are out of sync with the loaded object graph, the first generated UUID collides with an existing object (in the observed failure, the root PBXProject's own UUID), silently overwriting the root object so the saved rootObject points at the injected package reference. The bug has been latent in spm_dependency since it was introduced; the larger Pods object graph in the new stack merely exposed it.
Fix: route object creation through a new_object helper that keeps the deterministic counter but probes generate_uuid forward past any UUID already present in objects_by_uuid, guaranteeing uniqueness against the live object table. Repeated pod installs stay idempotent via the existing find-before-create dedup guards.
Scope: small and contained — 2 files, +126/-3, touching only scripts/cocoapods/spm.rb and a new standalone test scripts/cocoapods/__tests__/spm-test.rb. Already merged on main.
Applicable criteria: fix to a bug in core React Native (#2) and fix of an accidental breaking change (#6) — this repairs a break in the very SwiftPM feature being shipped in 0.87.
Target Branch
0.87
Link to commit or PR to be picked
react/react-native@1cdf784 (PR react/react-native#57576)
Description
This is a hotfix for a breaking regression introduced by the prebuilt/SwiftPM stack that is being picked into
0.87(see pick request #1344 and PR react/react-native#57578).Symptom: any library using
spm_dependencybreaks the build in prebuilt mode.pod installsucceeds, butxcodebuildcannot load the generated Pods project:This was caught by the first nightly containing the SwiftPM stack, which broke the
react-native-enriched-markdownjob in react-native-community/nightly-tests.Root cause:
spm_dependencyinjects package-reference objects from apost_installhook viaproject.new(...). CocoaPods'Pod::Projectuses a deterministic UUID counter and skips collision checks (it assumes a freshly generated project). When the counters are out of sync with the loaded object graph, the first generated UUID collides with an existing object (in the observed failure, the rootPBXProject's own UUID), silently overwriting the root object so the savedrootObjectpoints at the injected package reference. The bug has been latent inspm_dependencysince it was introduced; the larger Pods object graph in the new stack merely exposed it.Fix: route object creation through a
new_objecthelper that keeps the deterministic counter but probesgenerate_uuidforward past any UUID already present inobjects_by_uuid, guaranteeing uniqueness against the live object table. Repeatedpod installs stay idempotent via the existing find-before-create dedup guards.Scope: small and contained — 2 files, +126/-3, touching only
scripts/cocoapods/spm.rband a new standalone testscripts/cocoapods/__tests__/spm-test.rb. Already merged onmain.Applicable criteria: fix to a bug in core React Native (#2) and fix of an accidental breaking change (#6) — this repairs a break in the very SwiftPM feature being shipped in 0.87.