swiftauthenticationartifactoryswift-package-manager

How to add authentication for Swift in Xcode environment


The Swift package manager recently added support for registries for hosting binary packages. I have successfully created Swift packages and resolved them from a local Artifactory instance.

Setting up authentication directly for Swift can be done through the commandline:

swift package-registry set --global "https://artifactory.com/api/swift/swift"

swift package-registry login "https://artifactory.com/api/swift/swift" --username=MyUser --password=MyPassword

Now you can simply invoke: swift package resolve from the location of your Package.swift file.

However, Xcode seem incapable of reusing the stored credentials.

Is it possible to set up XCode such that the integrated Swift version has credentials for authentication? If it is possible, how is it done?


Solution

  • There is a bug on Xcode side.

    Xcode 14.3 doesn't use credentials (from netrc or keychain) for auth to spm registry

    Seems the fix is included in the Xcode 15 Beta!