Connect Swift to Artifactory

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

Configure your Swift client to connect to your Artifactory repositories. You can configure repositories per Swift project or globally.

Prerequisite: Before connecting your Swift client to Artifactory, you must have an existing Swift repository in Artifactory. For more information, see Create a Swift Repository.

To connect the Swift client to Artifactory:

  1. From your Swift project directory, run the following command to add the Artifactory repository to your Swift configuration:

    swift package-registry set "https://[JFrogPlatformURL]/artifactory/api/swift/<REPO_NAME>"

    Tip

    To configure the registry for all Swift projects, add the --global flag before the registry URL. You can run the --global command from any directory.

    Where:

    • [JFrogPlatformURL]: The URL of your JPD

    • <REPO_NAME>: The name of the target repository in Artifactory

    For example:

    swift package-registry set "https://company.jfrog.io/artifactory/api/swift/swift-virtual"

    The .swiftpm/configuration/registries.json file is created.

  2. Add the following snippet with your Artifactory authentication information to your ~/.netrc file:

    machine [JFrogPlatformURL] login <USERNAME> password <AUTH_TOKEN>

    Where:

    • [JFrogPlatformURL]: The base URL of your JPD

    • <USERNAME>: Your Artifactory username

    • <AUTH_TOKEN>: Your Artifactory identity token

    For example:

    machine company.jfrog.io login jeffry password B7r9P2tLqGvXzWcM5jN3yHkF6sD8aA1vS4uK0eI2oZp7xTqWcE5rVbN1mKjHgF

Note

You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see Use Artifactory Set Me Up for Configuring Package Manager Clients.

Connect to Swift Using HTTP

Swift uses HTTPS by default. If you need to connect using HTTP, open the .swiftpm/configuration/registries.json file and update the scheme in the "url" field to http.

Next steps: