Sven Schmidt alerted me to the fact that you can check in
Package.resolved to pin Swift package versions in Xcode-managed projects if you add the file from within the generated
project.xcworkspace file in your
git add *.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
You may have a
.gitignore rule that skips
*.xcodeproj/project.xcworkspace. Git will inform you about that. Mine was located in
~/.gitignore_global, actually, and I didn’t realize that.
Luckily, you can write
.gitignore exceptions with the
These only work on siblings. So these rules compose:
While these don’t:
What I ended up doing is adding as few rules to my global gitignore as possible while adding enough to add an exception for the resolved package dependencies file:
# Ignore generated Xcode project files except SwiftPM resolved packages to pin versions in teams
That’s now part of my
~/.gitignore_global and allows me to check in Swift package versions for team projects.
Thank you, Sven!