Closed ncharniauski closed 8 months ago
@ncharniauski Thanks for creating this. Have you tried entering the package registry identifier (e.g., mona.LinkedList
) rather than the Artifactory URL in the search box?
yes I did - package is not found.
Tracking with rdar://120735039
@ncharniauski A couple of things to check/try:
registries.json
(under ~/.swiftpm/configuration/
), please make sure you either don't have registries.json
in local workspace or the info in it is correct.@ncharniauski A couple of things to check/try:
- If you are using user-level
registries.json
(under~/.swiftpm/configuration/
), please make sure you either don't haveregistries.json
in local workspace or the info in it is correct.- After you type the package registry identifier in the search box, you might need to hit enter to trigger a search. Copy-paste to the search box should also trigger a search.
registries.json
under ~/.swiftpm/configuration/
I am afraid I am out of idea at the moment. I don't think the issue is Xcode not reading registry credentials from Keychain, because you should have gotten an error rather than 0 packages found.
0 packages found is the result of Xcode not being able to connect to my private registry. It couldn't connect, it doesn't know about the package ID i am looking for. This happens only if I am searching for my package by id.
If I enter registry URL into the search box, then I am getting authentication error. Xcode tries to grab credentials from Keychain and authenticate to my registry. This fails and I am getting prompted to enter my username/password as a fallback.
If I enter registry URL into the search box, then I am getting authentication error.
When you enter registry URL in the search box it is treated as the Git repo URL, so the authn error results from Xcode/SwiftPM trying to clone it and fails. In other words, that error and prompt don't have anything to do with registry.
Could it be this? https://forums.developer.apple.com/forums/thread/729959
I fixed the issue by going to ~/.gitconfig
and removing any reference to entries with [url "https://github.com/"] insteadOf = ...
or [url "ssh://git@github.com/"]
EDIT: I also have the GitHub account in Xcode, as well as the entry in ~/.netrc
.
Would you be able to clarify if this issue is reproducible for you with swift build
, swift test
, or any other SwiftPM CLI commands?
Could it be this? https://forums.developer.apple.com/forums/thread/729959 I fixed the issue by going to
~/.gitconfig
and removing any reference to entries with[url "https://github.com/"] insteadOf = ...
or[url "ssh://git@github.com/"]
EDIT: I also have the GitHub account in Xcode, as well as the entry in
~/.netrc
.
Nope. We are not hosting private package on GitHub. It is hosted in Jfrog Swift Registry.
Would you be able to clarify if this issue is reproducible for you with
swift build
,swift test
, or any other SwiftPM CLI commands?
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" ?
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.
@ncharniauski @MaxDesiatov @yim-lee
I am doing the same stuff but with AWS Code artifacts, there is docs to run a command called aws codeartifacts login
which should create a .swiftpm directory in root with registry configurations. This works for with Package.swift create keychain and all everything is perfect but not with .xcodeproj
But when I try to Add package from File -> Add Pacakge Dependencies and url in search bar it says repository cannot be accessed, followed the docs same 0 pacakges found everytime
So I wanna know is this issue with Xcode?
Okay, I dont know whether this is a bug or not. I tried putting this code snippet in user-level registries.json
// ~/.swiftpm/configurations/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
}
and then quit xcode and reopen again and try to add package from Xcode UI it works perfectly 🎉
I solved the same problem, took me a while. @ncharniauski your keychain setup is probably wrong as far as I can see from you screenshot. "Where" should be the url to the swift repository like this:
I had the same setup as you, then I updated the password entry in the keychain and it worked.
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
swift package-registry login https://example.jfrog.io/artifactory/api/swift/swift-registry-local \
--username myUser \
--password myToken
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:
{
"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
}
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.
@hbedekLU any success? got the same :)
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:
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
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