Skip to content

[0.87] SwiftPM: actually read the artifacts version pin back #1372

Description

@cipolleschi

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type Pick RequestPick requests to include commits inside a React Native release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions