Update every Package.resolved Xcode reads, not just the .xcodeproj#5
Merged
Conversation
The action only wrote the freshly-resolved pins to the lockfile embedded in the .xcodeproj (project.xcworkspace/.../Package.resolved). Projects built via a .xcworkspace resolve against the *workspace* lockfile instead, which the action never touched -- so dependency bumps landed in the project file but never reached `xcodebuild -workspace` builds, and the two files silently drifted (the project lockfile looked current while real builds compiled stale pins). Now the action discovers every lockfile Xcode reads -- the .xcodeproj-embedded one plus each sibling .xcworkspace's copy -- and patches each in place, values-only: - Preserves each file's schema version (v2/v3), originHash, and byte-exact SwiftPM formatting, so diffs are minimal with no formatting churn. - Only updates pins present in the fresh resolution; never removes pins that belong solely to a workspace's local packages (e.g. a transitive dep of a local SPM package the synthetic manifest never sees). - Won't author a workspace lockfile from scratch (it would be incomplete); only keeps existing ones current. - changed-count now spans all lockfiles; dependencies-changed is true if any lockfile would change. Adds test/test_merge.py (pure-Python, no Swift toolchain) covering discovery and the in-place merge, wired into CI as a fast Linux `unit` job. Updates README and CHANGELOG; the old "project-internal Package.resolved only" caveat is now obsolete. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
maximbilan
force-pushed
the
fix/update-all-lockfiles
branch
from
July 23, 2026 13:42
95eb91c to
2bacb4f
Compare
Foundation's JSONEncoder (what SwiftPM/Xcode use) writes raw UTF-8; Python's json escapes non-ASCII to \uXXXX by default, which would rewrite a package name or URL containing non-ASCII on the first run. No-op for the common ASCII-only case; keeps output byte-identical to Xcode's for arbitrary repos. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
The action only wrote resolved pins to the lockfile embedded in the
.xcodeproj:But Xcode keeps a separate
Package.resolvedper container. A project built through a.xcworkspace—xcodebuild -workspace, which is what most CI/release builds run — resolves against the workspace lockfile at<MyApp>.xcworkspace/xcshareddata/swiftpm/Package.resolved. The action never touched it.So weekly dependency bumps landed in the
.xcodeprojlockfile but never reached real builds, and the two files silently drifted — the project lockfile looked current whilexcodebuild -workspacekept compiling the stale pins. This was even a documented caveat in the README.The fix
Discover every lockfile Xcode reads — the
.xcodeproj-embedded one plus each sibling.xcworkspace's copy — and patch each in place, values-only:originHash, and byte-exact SwiftPM formatting → minimal diffs, no formatting churn.changed-countnow spans all lockfiles;dependencies-changedistrueif any lockfile would change.Local packages' own lockfiles are correctly excluded.
Testing
test/test_merge.py(pure-Python, no Swift toolchain) — 6 tests covering target discovery and the in-place merge; wired into CI as a fast Linuxunitjob.swift package update: a stale project (v3) + stale workspace (v2) lockfile with a workspace-only pin → both updated, formats &originHashpreserved, the workspace-only pin survived untouched, idempotent on re-run.Note for consumers
Consumers pinned at
@v1won't get this untilv1is re-pointed or a new release is cut after merge.🤖 Generated with Claude Code