0x416e746f6e
0x416e746f6e

Reputation: 10136

Specify dependency branch or commit ID in Swift PM's Package.swift

Is there a way to define dependency in Package.swift that would point at a certain branch latest commit, or even to just a specific commit ID (just like it is possible with Carthage)?

Use case would be, let's say I have a library repo where I would like to branch out and make some changes, and then be able to test them out in a dependent project.

Upvotes: 20

Views: 12215

Answers (3)

Saad Rehman
Saad Rehman

Reputation: 403

It is possible.

  1. Go to project
  2. Click on "Package Dependencies" Tab
  3. Double click on the package you want to change the branch of
  4. Specify the branch/commit.

Choose branch or commit here

Upvotes: 7

TaborKelly
TaborKelly

Reputation: 3595

As of Swift 4 you can use .branch() and .revision() as described in PackageDescription.md

Upvotes: 11

Kostiantyn Koval
Kostiantyn Koval

Reputation: 8483

Not yet, but swiftpm team is working on. Now you must specify a package version when declaring a dependency.

import PackageDescription

let package = Package(
    name: "Example",
    dependencies: [
        .Package(url: "https://github.com/somePackage", "1.0.0")
    ]
)

In the future it will be possible, there was a discussion to add Version Locking but its not accepted and implemented yet.

For your use case you can fork the repo, do the changes, test them and then add a version tag to your fork. Now it's much more easier to do changes with Editable Packages functionality.

Upvotes: 1

Related Questions