Swift Repositories
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns. The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. The tool compiles and links Swift packages, managing dependencies, versioning, and supporting flexible distribution and collaboration models. For more information, see Swift documentation and Swift Package Manager.
Important
There is currently no official public Swift registry for Swift package manager. The URL https://swiftpackageregistry.com/ is not a Swift registry. It is an HTML catalog of Swift packages that are hosted on Git servers.
Artifactory fully supports Swift repositories, including the following capabilities:
- Robust Metadata Capabilities: Calculate metadata for Swift packages hosted in Artifactory's local repositories, and validate remote Swift repository metadata.
- Unified Repository Management: Consolidate all your Swift repositories in Artifactory as a single source of truth. Set up secure local repositories, access cached versions of remote registries, and create a single access point for all sources with virtual repositories.
- Support for Swift Package Manager: Natively use the Swift command line tool to deploy, remove, and manage packages in Artifactory.
Get Started with Swift
To get started working with Swift, complete the following main steps:
- Create a Swift Repository
- Connect Swift to Artifactory
- Deploy and resolve Swift packages

Create a Swift Repository
This topic describes how to create a Swift repository. This is required before publishing and installing Swift packages. There are three primary types of repositories:
-
Local repositories: Store and share first- and second-party packages with your organization
-
Remote repositories: Download packages from any remote location, including external package registries or other Artifactory instances
Note
Swift remote repositories are supported as private Swift registries, including Smart Remote repositories. There is currently no official public Swift registry. When a public Swift registry becomes available, it will be supported out of the box.
- Virtual repositories: Aggregate remote and local repositories, enabling your organization to scale by providing a single URL that provides access to multiple repositories and types
For more information on JFrog repositories, see Repository Management.
Prerequisite: You need Admin or Project Admin permissions in Artifactory to create a repository. If you don't have Admin permissions, the option will not be available.
To create a Swift repository:
-
In the Administration tab, click Repositories | Create a Repository.

-
Select the type of repository you want to create: local, remote, or virtual.
-
Select the Swift package type.
-
Configure the required fields for the repository:
-
For local repositories, in the Repository Key field, type a meaningful name for the repository. For example,
swift-local. For more information on local repositories and their settings, see Local Repositories. -
For remote repositories, verify the Repository URL and update as needed. For more information on remote repositories and their settings, see Remote Repositories.
Swift remote repositories can only connect to registries that use the Swift registry protocol. URLs like https://swiftpackageregistry.com are HTML catalogs that do not host any packages, but point to GitHub repositories that host packages.
-
For virtual repositories, select one or more local or remote repository types to include in the virtual repository. For more information on virtual repositories and their settings, see Virtual Repositories.
-
-
Click Create Repository. The repository is created and the Repositories window is displayed.
Connect Swift to Artifactory
Configure your Swift client to connect to your Artifactory repositories. You can configure repositories per Swift project or globally.
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.
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:
-
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
--globalflag before the registry URL. You can run the--globalcommand 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.
- Add the following snippet with your Artifactory authentication information to your
~/.netrcfile:
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.
Next steps:
Connect to a Specific Swift Repository
To connect directly to a specific Swift repository in Aritfactory and bypass any project-specific or global configurations, run this command:
swift package-registry login https://[JFrogPlatformURL]/artifactory/api/swift/<REPO_NAME> \
--username <USERNAME> \
--password <AUTH>
Where:
[JFrogPlatformURL]: The URL of your JPD<REPO_NAME>: The name of the target Artifactory repository<USERNAME>: Your Artifactory username<AUTH>: Your Artifactory identity token or password. For more information about using a password securely, see Centrally Secure Passwords
For example:
swift package-registry login https://company.jfrog.io/artifactory/api/swift/swift-virtual \
--username jeffry \
--password B7r9P2tLqGvXzWcM5jN3yHkF6sD8aA1vS4uK0eI2oZp7xTqWcE5rVbN1mKjHgF
Deploy Swift Packages
Note
Swift packages must be deployed according to the following structure, otherwise they will not be indexed:
<SCOPE>/<NAME>/<NAME>-<VERSION>.zip<SCOPE>/<NAME>/<VERSION>
-
From the root directory of the package, run this command to create a source archive for the working tree:
swift package archive-source -
Publish the archive using one of the following commands, based on your version of the Swift client:
-
Version 5.9 or later:
swift package-registry publish <SCOPE>.<NAME> <VERSION>Where:
<SCOPE>: The owner or namespace of the package, usually the scope of the source code repository URL<NAME>: The name of the project as defined in thePackage.swiftfile<VERSION>: The version of the package, usually corresponding with a tag in the source code repository
For example:
swift package-registry publish aurora-fi.aurora-auth-ios 2.1.4 -
Version 5.8 or earlier:
curl -X PUT -u<USERNAME>:<AUTH> \ -H "Accept: application/vnd.swift.registry.v1+json" \ -F source-archive="@<SOURCE_ARCHIVE_PATH>" \ https://[JFrogPlatformURL]/artifactory/api/swift/<REPO_NAME>/<SCOPE>/<NAME>/<VERSION>Where:
<USERNAME>: Your Artifactory username<AUTH>: Your Artifactory identity token or secure password<SOURCE_ARCHIVE_PATH>: The local file path to the source archive for the package[JFrogPlatformURL]: The URL of your JPD<REPO_NAME>: The name of the target repository in Artifactory<SCOPE>: The owner or namespace of the package, usually the scope of the source code repository URL<NAME>: The name of the project as defined in thePackage.swiftfile<VERSION>: The version of the package, usually corresponding with a tag in the source code repository
For example:
curl -X PUT -ujeffry:B7r9P2tLqGvXzWcM5jN3yHkF6sD8aA1vS4uK0eI2oZp7xTqWcE5rVbN1mKjHgF \ -H "Accept: application/vnd.swift.registry.v1+json" \ -F source-archive="@/opt/build/agent/work/aurora-auth-ios-2.1.4.zip" \ https://company.jfrog.io/artifactory/api/swift/swift-releases/aurora-fi/aurora-auth-ios/2.1.4
-
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.
Resolve Swift Packages
-
List all dependencies in the
Package.swiftfile for the package you want to resolve:dependencies: [ .package(id: "<SCOPE>.<NAME>", from:"<VERSION>") ]Where:
<SCOPE>: The owner or namespace of the package, usually the scope of the source code repository URL<NAME>: The name of the project as defined in thePackage.swiftfile<VERSION>: The version of the package, usually corresponding with a tag in the source code repository
For example:
dependencies: [ .package(id: "apple.swift-nio", from: "2.65.0"), .package(id: "vapor.fluent", from: "4.8.0"), .package(id: "pointfreeco.swift-composable-architecture", from: "1.10.0"), .package(id: "google.swift-protobuf", from: "1.27.0") ] -
Run this command:
swift package resolve
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.
Additional Swift Information
The following pages provide additional information about using Swift with Artifactory:
Re-Index a Swift Repository
You can trigger an asynchronous re-indexing of a local Swift repository either through the UI or using the REST API.
This reindexes the git index and, as a result, will also index the remote repositories.
In the Artifact Tree Browser, select your Swift repository, right-click and select Recalculate Index from the list. This requires Admin privileges.
To reindex a Swift repository through the REST API refer to the following REST API: Calculate Swift Index
Swift Repository Structure
The Swift package structure is as follows.
`├── Package.swift ├── README.md ├── Sources`
`│ └─ Hello` `│ └── hello.swift └── Tests` `└─ HelloTests └── helloTests.swift └─ LinuxMain.swift`
Swift Deployment Structure
All deployment of Swift packages into Artifactory can be deployed under the following structures:
<SCOPE>/<NAME>/<NAME>-<VERSION>.zipstructure.<SCOPE>/<NAME>/<VERSION>: Based on the following Swift Publish API.
Note that the packages have to be deployed according to this structure, otherwise they will not be included in the index file.
Swift Limitations in Artifactory
The following are the limitations of Swift in Artifactory:
-
Supported versions: Using Swift with Artifactory requires Swift version 5.7 and above, and Artifactory 7.41.4 and above.
-
Authentication support: Swift 5.8 and above requires at least Artifactory 7.55.1 for proper authentication support.
-
Deployment structure: Swift packages must be deployed in the following structure in order to be indexed properly in Artifactory:
<SCOPE>/<NAME>/<NAME>-<VERSION>.zip<SCOPE>/<NAME>/<VERSION>
Updated about 1 month ago
