Dependency on (very) active branch doesn't pull new commits

I'm writing a package that relies on another package that I manage (Netswift). I've setup a bleeding_edge branch there, where I commit every few hours (i.e when I notice access control is wrong, or any other small edit).

Now my current package has a dependency on the github repo for Netswift, with that bleeding_edge branch, as pictured below:

dependencies: [
    .package(url: "https://github.com/MrSkwiggs/Netswift", .branch("bleeding_edge")),
]

Unfortunately, resolving the dependency graph by any of the following means (updating Package.swift with an empty space somewhere, running swift package update) does not pull new commits from that branch.

The only way I found to force-update is to specify a different branch, resolve dependerency graph, then revert back to the branch I actually need.

Is this intended behaviour ?

resolve and update are two different things:

  • resolve attempts to keep the exact same versions and revisions as last time (which are recorded in Package.resolved). That means it will only trigger an update if you have changed the constraints since the last time, so that what you had before is no longer valid. resolve is what build, test, run etc. do implicitly.
  • update deliberately asks for the whole graph to be evaluated anew, trying to switch to the newest versions or revisions. It throws away Package.resolved and starts over from scratch.
$ swift package update

(Xcode has a similar commands in the menu under File → Swift Packages.)

1 Like

Also, if you want to work on both packages in tandem, you can do this:

swift package edit Netswift

Then SwiftPM will check out Netswift under Packages/Netswift. At that point SwiftPM is pointing directly at those sources, so you can edit them directly. When you are done, push whatever changes you’ve made in the Packages/Netswift repository and then do this:

swift package unedit Netswift

(Note that if you want to use this strategy with Xcode, you will have to do swift package generate-xcodeproj, because Xcode 11’s direct support for packages ignores edit mode.)

3 Likes

Thanks a lot for the answer, I figured swift package update would do just what you said, but it didn't which is why I was confused. Using the xcode File menu did do the trick, however. I'm curious as to what the difference is...

That sounds fishy. They are supposed to be identical. You can report probable bugs at bugs.swift.org.

1 Like

The same problem in Xcode 12.1, have to use .revision(<commit_hash>) for now :cry:

Terms of Service

Privacy Policy

Cookie Policy