Configure the Swift Client to Work Opposite Artifactory

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide
ft:sourceType
Paligo

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.

  1. Navigate to Application Module | Artifactory | Artifacts.

  2. Select the desired repository.

  3. 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:

      1. To set your Swift registry, run the following command:

        swift package-registry set --global https://example.com/artifactory/api/swift/swift-local
      2. 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:

  1. To set your Swift registry, run the following command:

    swift package-registry set --global https://example.com/artifactory/api/swift/swift-local
  2. To login to the registry using Swift, run the following command:

    swift package-registry login https://example-registry.com \
        --username jappleseed \
        --password alpine \
  3. 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
    }