How to add local Swift Package as dependency?

Well, Xcode 11 beta 2 suggests only remote URLs, right?
Can I add local Swift Package as dependency to test it?

You can drag the package into a workspace/project to add it as a local package.


No luck.
It adds only Package.swift.
Compiler error: No such module 'PackageDescription'.

Clibgit$ git init
Clibgit$ git add .
Clibgit$ git commit -m "Initial Commit"
Clibgit$ git tag 1.0.0

// other package
import PackageDescription

let package = Package(
    name: "example",
    dependencies: [
        .package(url: "../Clibgit", from: "1.0.0")
        //.package(path: "../Clibgit") // is also fine

And if you want to add to your app target.
File -> Swift Packages -> Add Package Dependency...
Enter package repository URL -> file:///Users/.../Clibgit -> Next.
Note: you need to commit to git here. If your package dose not commit to git, Xcode can't find it.

Those are very different.

The URL one requires it to be pointing at a git repository and treats that repository the same as it would a remote one, cloning it and checking out particular versions or revisions. The source you see in Xcode is managed by SwiftPM and will be “locked” and uneditable.

The path one just directly uses whatever is currently in the file system at that location. I think you can even use it that way without either package having a Git repository at all. You will be able to edit the source you see in Xcode directly.

(Caveat: I’m speaking in terms of Xcode 10.2, but the related documentation of SwiftPM looks like it’s still the same.)


Just drag and drop the folder where Package.swift is located too Xcode and then you can link this package to targets. I used this approach many times already without any issues.

Terms of Service

Privacy Policy

Cookie Policy