I have a local dependency in my Package.swift
in the form of
.package(url: "file:///Users/User/Documents/.../my-dependency", .branch("master")),
The local dependency is under development. I wish to update to the latest version, but I cannot find a way to update only that package without having to pull and rebuild all the other project dependencies. So far I have to pull and rebuild Vapor and Fluent every time I make a small change to a local dependency (assuming I even have internet access).
When I run swift package update --help
I see there is an instruction :
POSITIONAL ARGUMENTS:
packages The packages to update (optional)
However, whenever I try something like swift package update my-dependency
or swift package update My-Dependency
, it does the same thing and re-pulls all.
How do I go about updating this single dependency? And assuming I eventually do want to update all my other third-party dependencies, how do I tell SPM to check if there is an actual change to the package on GitHub before re-pulling and rebuilding it?
To resolve, Open the project from the project panel, select the project (not the targets), then select the "Swift Packages" tab. Double click on the package you want to update and change the minimum version to the next major version.
In order to cache the dependencies, they should be located in the project directory, but by default, SPM downloads the dependencies into the system folder: ~/Library/Developer/Xcode/DerivedData.
A package dependency consists of a Git URL to the source of the package, and a requirement for the version of the package. The Swift Package Manager performs a process called dependency resolution to figure out the exact version of the package dependencies that an app or other Swift package can use.
I just stumbled upon this question and found that the solution to "How to update swift dependencies in Xcode" has probably changed now that Swift Packages have been around for a few years. For me, the solutions was to simply go to File -> Swift Packages -> Update to Latest Package Versions. Show activity on this post.
To resolve, Open the project from the project panel, select the project (not the targets), then select the "Swift Packages" tab. Double click on the package you want to update and change the minimum version to the next major version. Show activity on this post.
Many of the problems with packages not updating are because the swift package version rules limit the automatic package updates to the current major version only, i.e v3.3.1 of a package will update to v3.4.0, but will not update automatically to v4.0.1.
I found the solution :
.package(path: "path/to/dependency")
No need to run swift package update
, it builds with the current local version. Also no need to commit the changes in the dependency each time.
See answer here by rounak
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With