swift-package-manager: Xcode 14.3 doesn't use credentials (from netrc or keychain) for auth to a package registry

Description

I’d tried to use this solution (self hosted spm registry ) The main thing is - after success auth, utility append new credentials to ~/.netrc file or mac os keychain In my case all credential was appended, but credential getting from netrc or keychain only when i use command line utility If i try to use Xcode, i got auth error status response that means credentials didn’t send. I’ve checked request headers, and exactly as i thought, credential didn’t send

In my case file content seems like that:

.swiftpm/configuration/registries.json

{
  "authentication": {
    "spm-registry.net": {
      "type": "token"
    },
  },
  "registries" : {
    "scope" : {
      "url" : "https://spm-registry.net/api/spm-registry/"
    }
  },
  "version" : 1
}

~/.netrc

machine spm-registry.net 
login token 
password <TOKEN>

Expected behavior

Xcode use credentials from netrc or keychain

Actual behavior

Credential was used only when i run cmd utility

Steps to reproduce

  1. Install Xcode 14.3
  2. Setup registries url by command line
  3. Setup registries auth by command line
  4. Run your self-hosted spm registry
  5. Try to resolve dependencies by Xcode application

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version && uname -a)

###############################

$ swift --version
swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0

###############################

$ swift package  --version
Swift Package Manager - Swift 5.8.0

###############################

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 13.1 (22C65)
      Kernel Version: Darwin 22.2.0
      ...

###############################

$ system_profiler SPDeveloperToolsDataType
Developer:

    Developer Tools:

      Version: 14.3 (14E222b)
      Location: /Applications/Xcode.app
      Applications:
          Xcode: 14.3 (21812)
          Instruments: 14.3 (64559.163)
      ...

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 30 (15 by maintainers)

Most upvoted comments

@FirstAM The fix is in Xcode. We will post back here when it becomes available.

Seems to be included in the Xcode 15 Beta!

@yim-lee Can you confirm this will be available in a Xcode 14.x.x update or is it more likely this will be available only in the upcoming Xcode 15 beta?

Xcode resolves private Artifactory dependencies listed in Package.swift just fine. This is not the issues. The issue is only with adding private packages to application xcproject directly from the Xcode UI:

@ncharniauski Can you create a new issue detailing the steps it takes to reproduce the issue? Please include example of values you enter in the UI. e.g., do you type in Artifactory URL or package identifier?

new issue is created: https://github.com/apple/swift-package-manager/issues/7237

Xcode resolves private Artifactory dependencies listed in Package.swift just fine. This is not the issues. The issue is only with adding private packages to application xcproject directly from the Xcode UI:

@ncharniauski Can you create a new issue detailing the steps it takes to reproduce the issue? Please include example of values you enter in the UI. e.g., do you type in Artifactory URL or package identifier?

Package registry credentials need to be added to Keychain via the swift package-registry login command or manually (by creating an item under “Internet Passwords”).

At the end you should have an entry like this in Keychain: image

Note that this is different from source control account. Registry operations do not use source control credentials.

If it still doesn’t work after ensuring the registry credentials are in Keychain, one thing you might check is if there is more than one entry for the same registry in Keychain. In this case, delete all the entries for the registry and create a new entry again. We don’t know what causes multiple entries to be saved for the same registry, for we can’t reproduce it consistently, so it would be great to get more information if that’s what’s happening for you.

@yim-lee The multiple credentials issue repeatedly happened to me. I also was unable to connect to an authenticated repo with Xcode 15. I’ve found that this problem seems to be due to upgrading from Xcode 14 to Xcode 15. I’ve installed Xcode through the App Store and was constantly having these problems. Once I deleted Xcode, and also deleted Xcode settings files like com.apple.dt.Xcode in locations like ~/Library/Application Scripts , ~/Library/Preferences , ~/Library/Containers, ~/Library/Developer, and ~/Library/Saved Application State followed by a reinstall of Xcode directly from the App Store, both of my problems disappeared and I stopped getting duplicate credentials in keychain and was able to connect to the authenticated repo.