Xcode 12 can't add package dependency from ssh?

I have a local file server with git repositories and ssh access. I have several swift packages stored there, and some of them have been successfully added as dependencies in projects using Xcode 11.

I am now unable to add any package dependencies like this in Xcode 12.

I can successfully clone the repo from the Source Control -> Clone... menu so I know the repo is valid.

The steps I am following are to add the dependency:
  1. File -> Swift Packages -> Add Package Dependency...

  2. Enter: ssh://MyServer.local/path/to/git/repo

  3. Xcode prompts for credentials -> success

  4. Xcode asks for the import rules, with correctly filled in version numbers (so I know it can access the repo at this point)

  5. I accept the defaults, click "next"

  6. I get the following error:

The source control operation failed because no working copy could be found. Make sure the file is in a valid working copy and try again.

Any idea how resolve this? Existing SPM packages resolve and work correctly, but I can't add any new ones.

Replies

Ok I had some more time to experiment. It looks like the package repository must have a branch called "master" for this to work. If the main branch in the package you're trying to import is called anything else, like "trunk" or "main" for example, adding the dependency will fail. This is particularly bad because creating a new package in Xcode (File -> New -> Swift Package...) creates a git repo with a branch called "main", not "master"!
  • What is the solution? GitHub moved away from 'master' to 'main' branch strategy last year!

Add a Comment