To use Artifactory with your Swift CLI, you must generate an access token. Then you can proceed to resolve and deploy the relevant Swift package.
Navigate to Application Module | Artifactory | Artifacts.
Select the desired repository.
Select Set Me Up and follow the instructions. You can log in to your client using one of these methods:
Log in with your username and password.
Log in using an authentication token in your Swift login command.
Note
From Artifactory version 7.55.1, Swift 5.8 is supported with authentication support. For more information, see the Swift Documentation.
To log in using an authentication token:
To set your Swift registry, run the following command:
swift package-registry set --global https://example.com/artifactory/api/swift/swift-local
To login to the registry using Swift, run the following command:
swift package-registry login https://example-registry.com \ --username jappleseed \ --password alpine \
This will create the
.swiftpm/configuration/registries.json
file as:{ "registries": { "[default]": { "url": "https://example-registry.com" } }, "authentication": { "example-registry.com": { "type": "basic", "loginAPIPath": "artifactory/api/swift/swift-local" } }, "version": 1 }
Starting from Swift version 5.8, you can use the new Swift login command. For more information, see the Swift Documentation.
To use the new Swift login:
To set your Swift registry, run the following command:
swift package-registry set --global https://example.com/artifactory/api/swift/swift-local
To login to the registry using Swift, run the following command:
swift package-registry login https://example-registry.com \ --username jappleseed \ --password alpine \
This will create the
.swiftpm/configuration/registries.json
file as:{ "registries": { "[default]": { "url": "https://example-registry.com" } }, "authentication": { "example-registry.com": { "type": "basic" "loginAPIPath": "artifactory/api/swift/swift-local" } }, "version": 1 }