Swift Package Manager fails to clone from private Git repositories

If you are using Swift Package Manager as part of the xcodebuild process, you may find that this fails with the following error message:

xcodebuild: error: Could not resolve package dependencies:
  Authentication failed because the credentials were rejected

This issue will only occur when trying to access private git repos when using SSH key authentication.

This is caused by a bug in the way that xcodebuild handles SSH keys and has been a known bug since the debut of Xcode 11, occurring both locally, but more specifically, in a CI environment.

The suggested workaround would be to switch the package url from ssh to https in your Xcode project and use a personal access token in place of your GitHub password for security.

You can store this token in an environment variable, much like the Fastlane match password, so that the token remains private.

Was this article helpful?
0 out of 0 found this helpful



Article is closed for comments.