Target Branch
0.87
Link to commit or PR to be picked
react/react-native#57762
Landed on main as react/react-native@b0b5409
Description
spm add --version <ver> / spm update --version <ver> already wrote an artifactsVersionOverride into the .spm-injected.json marker, and readArtifactsVersionOverride already existed to read it back — but nothing ever called it. Only the write half was wired.
The sole resolver, determineVersion, went straight from the --version flag to node_modules/react-native/package.json. So after spm add --version X, a later flagless spm update silently re-points the project at package.json's artifact slots while the marker still claims X. --version was effectively single-use, which is why the standing advice has been to pass it on every invocation — advice that was working around this bug.
The fix inserts the pin between the two existing sources: --version → pinned override → react-native/package.json, and logs one line when the pin is the source so a stale pin is diagnosable rather than silent.
Requested for 0.87 because the experimental SwiftPM support ships on that line, and anyone pinning an artifact version there gets silently re-pointed on the next spm update. Low risk: 15 lines of resolution logic plus doc corrections, fully covered by unit tests (including the three pre-existing fallback paths, which are pinned so this cannot regress them).
Target Branch
0.87
Link to commit or PR to be picked
react/react-native#57762
Landed on
mainas react/react-native@b0b5409Description
spm add --version <ver>/spm update --version <ver>already wrote anartifactsVersionOverrideinto the.spm-injected.jsonmarker, andreadArtifactsVersionOverridealready existed to read it back — but nothing ever called it. Only the write half was wired.The sole resolver,
determineVersion, went straight from the--versionflag tonode_modules/react-native/package.json. So afterspm add --version X, a later flaglessspm updatesilently re-points the project atpackage.json's artifact slots while the marker still claimsX.--versionwas effectively single-use, which is why the standing advice has been to pass it on every invocation — advice that was working around this bug.The fix inserts the pin between the two existing sources:
--version→ pinned override →react-native/package.json, and logs one line when the pin is the source so a stale pin is diagnosable rather than silent.Requested for 0.87 because the experimental SwiftPM support ships on that line, and anyone pinning an artifact version there gets silently re-pointed on the next
spm update. Low risk: 15 lines of resolution logic plus doc corrections, fully covered by unit tests (including the three pre-existing fallback paths, which are pinned so this cannot regress them).