Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 919
0x416e746f6e Avatar asked Oct 09 '16 13:10

0x416e746f6e


3 Answers

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

like image 192
Saad Rehman Avatar answered Nov 15 '22 20:11

Saad Rehman


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

like image 21
TaborKelly Avatar answered Nov 15 '22 20:11

TaborKelly


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.

like image 22
Kostiantyn Koval Avatar answered Nov 15 '22 21:11

Kostiantyn Koval