Joe Sherwood

Swift Package Manager Dependency from a Standalone Git Repository with SSH

Adding a Swift Package Manager dependency to an Xcode 15 project can easily be done when the source is Apple Swift Packages or via an Xcode account connection to the likes of Github or GitLab. However, one can also be sourced from a standalone git repository over ssh, albeit in a non-obvious way.

Empty Xcode 'Add Package Dependencies...' pane

Intuitively, one would think the + in the bottom left corner of this pane would be the place to try. Though that just allows for adding accounts to 3rd party hosting services. The Add Local... button, as its name implies, only works for instances of a dependency stored locally on the machine.

Add a ssh:// path to the git repository in the search field.

The trick is to add the custom url to what appears to be a search box in the upper right, which will fetch the desired dependency. It is labelled Search or Enter Package URL, so this does appear to be the intended usage. Even so, I have figured this out, to subsequently forget it the next time I’ve needed it, so many times that I’m leaving this breadcrumb for future me to find.

Configure package sourced from custom git repository URL.

After this search step, the package behaves like any other, which certainly was the goal all along.