swift-package-manager: Xcode 15.1 - not able to add private package dependencies to app project
Description
We are hosting Swift package using https://jfrog.com/help/r/jfrog-artifactory-documentation/swift-registry. Registry is protected and requires authentication. Swift registry works fine using CLI.
When I add a dependency to an application project from Xcode UI (File -> Add package dependency)or via this UI:
Xcode displays error “Authentication failed because the credentials were rejected”
Xcode is able to resolve the same private package dependency just fine if I add dependency to a Swift package project via Package.swift"
My registries.json:
{
"authentication" : {
"example.jfrog.io" : {
"loginAPIPath" : "/artifactory/api/swift/swift-registry-local",
"type" : "basic"
}
},
"registries" : {
"[default]" : {
"supportsAvailability" : false,
"url" : "https://example.jfrog.io/artifactory/api/swift/swift-registry-local"
}
},
"version" : 1
}
I do have registry credentials stored on keychain. It is just one credentials set. Xcode asks to access registry creds on keychain and I grant the permission. I tested with both registry authentication types: basic and token. Both types of authentication fail when adding dependency package from Xcode UI.
Expected behavior
Xcode UI should allow adding protected package dependencies to application projects.
Actual behavior
Xcode displays authentication error when I attempt to add protected package dependency:
Steps to reproduce
- Install Xcode 15.1
- Set up SPM registry that requires authentication (such as https://jfrog.com/help/r/jfrog-artifactory-documentation/swift-registry)
- Setup registry URL by command line: package-registry set --global “url”
- Setup registries auth by command line: package-registry login “url” --username “uname” --password “pwd”
- Verify registries.json file is created with appropriate authentication type.
- Verify appropriate Keychain Internet Password is created for registry host URL
- Open application project in Xcode and go to File->Add Package Dependencies…
- In the “Add Package” window, in the top right corner input field “Search or Enter Package URL” enter registry URL
- Xcode displays “Authentication failed because the credentials were missing” window asking to re-enter user name and password
- Reentering username/password does also fails with authentication error
Swift Package Manager version/commit hash
No response
Swift & OS version (output of swift --version ; uname -a)
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5) Target: x86_64-apple-macosx13.0 Darwin 22.6.0 Darwin Kernel Version 22.6.0: Wed Oct 4 21:25:26 PDT 2023; root:xnu-8796.141.3.701.17~4/RELEASE_X86_64 x86_64
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 19 (7 by maintainers)
SwiftPM CLI works just fine. Furthermore, Xcode is resolving our private package just fine if package is imported into another package via Package.swift. My test Package lists our private SPM package as dependency on Package.swift. The moment I open the test Package in Xcode, private dependency gets resolved and Package.resolved gets generated.
When I try to add private SPM package dependency to TestApp.xcodeproj via >File>Add Package Dependency> entering Jfrog registry URL in the Search box , this is when Xcode is not able to resolve the package.
What is the difference in how Xcode resolves packages listed on the Package.swift vs via manually resolving through “Add Package Dependency” ?
Nope. We are not hosting private package on GitHub. It is hosted in Jfrog Swift Registry.
Very interested in this topic. @ncharniauski where you able to solve this issue ?
@gurelkaynak I did try your solution but I am still not able to retrieve the packages.
The configuration I tried:
Setup the swift registry
swift package-registry set --global "https://example.jfrog.io/artifactory/api/swift/swift-registry-local"Use the login command to store credential in keychain
with myUser my artifactory user and myToken the token provided by artifactory with the set me up action
Here is the registries.json than I am getting:
At this point I tried to search for my package in the search bar but not able to get anything.
I tried to put as URL:
None of these solutions is working.
Okay, I dont know whether this is a bug or not. I tried putting this code snippet in user-level registries.json
and then quit xcode and reopen again and try to add package from Xcode UI it works perfectly 🎉
Unfortunately, this issue should be closed here then. This repository hosts the open-source SwiftPM project and its CLI, it does not track Xcode-specific issues. Please file anything Xcode-specific at https://feedbackassistant.apple.com.