ARTIFACTORY: How to configure a Swift registry and resolve related errors

AuthorFullName__c
DaYoun Kang
articleNumber
000005481
FirstPublishedDate
2022-11-30T09:26:00Z
lastModifiedDate
2025-05-15

ARTIFACTORY: How to configure a Swift registry and resolve related errors

How to configure a Swift package registry

Once you create a Swift repository from the Artifactory UI, we will need to configure the client in order to use it.

From your client, run the below command to set a Swift package registry:

swift package-registry set https://[ARTIFACTORY_URL]/artifactory/api/swift/[swift-repo-name]


When the above command is run, it will create a .swiftpm/configuration/registries.json file. You can verify this file to check if the registry is set correctly.

E.g:

{
  "registries" : {
    "[default]" : {
      "url" : "https://[ARTIFACTORY_URL]/artifactory/api/swift/[swift-repo-name]"
    }
  },
  "version" : 1
}
How to resolve related errors while setting up a Swift package registry

Case #1

Error:

error: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-package-registry (No such file or directory)

Solution:

Set your Xcode’s toolchain as the installed Swift toolchain

User-added image

And add the Swift toolchain to your PATH environment variable:

$ export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"

Case #2

Error:

Error: Could not find Package.swift in this directory or any of its parent directories.

Solution:
Run the “swift package-registry set” command in the root directory of a package.