I'm working on a Swift package and on an app using it, with Xcode 14.2
Due to incremental updates, I reference my package from my app with the branch I'm working on (for example: feature/current-dev
)
Then I push a new commit on the package repository. How do I get this very last commit in the app?
Here's what I tried:
At this point I feels Xcode is trolling me. Is this the expected SPM behaviour? How to get the last commit?
It's a pity that this workflow is not supported by UI commands. (Xcode 16.1)
Discussions on topic (1)
In you Package.resolved
you can find your dependency in pins
field and
update state.revision
commit hash to latest from your branch.
Xcode will automatically update dependency and all its own dependencies.
(At least it works for Xcode 16.1)
Package.resolved
If it doesn't work, make sure that your Package.resolved
is using V3 Schema because it contains originHash
.
V3 Schema was introduced in 5.10
prefer versions in package.resolved file when one exists and matches the original manifest by @tomerd in #6698
You can see current version at the bottom of .resolved
file.
To support v3 you need to make sure that Swift 5.10
is used both by Xcode and any SPM package that is added as a reference to Xcode project/workspace.
This is a way to edit SPM package along side with Xcode project/workspace.
To add a reference, just drag and drop package folder anywhere into your workspace project navigator.
Package stored in same repository (that contains modules of your project)
Checkout of external SPM dependency that is already resolved in workspace.
This is now an official way to enter editing mode for your dependencies on Xcode 16, confirmed by Developer Tools Engineer on apple forums. To exit editing mode, just delete the reference.
In Xcode 16 "Add local" button is no longer have the same effect
as described in Apple documentation Editing a package dependency as a local package on 01/02/2025.
In Xcode 16 it just replaces external dependency with local one.
Swift 5.10 became default for Xcode 15.3. You have two options:
Make sure you have at least 5.10
in the comment on top of Package.swift
manifest.
// swift-tools-version:5.10
Package.resolved
If you resolve dependencies for Xcode project
MyApp.xcworkspace/xcshareddata/swiftpm/Package.resolved
If you resolve dependencies for SPM package file is
next to manifest Package.swift
for this SPM package.