Swift
Use a Swift registry to publish and consume Swift packages with Swift Package Manager (SwiftPM). Harness exposes a registry URL compatible with swift package-registry commands for authentication, publishing, and dependency resolution.
Prerequisites
Swift 5.9 or later with Swift Package Registry support (
swift package-registry --help).Access to a Harness account with appropriate permissions to create registries and connectors.
Create a Swift Artifact Registry
Navigate to the Artifact Registry module in your Harness project.
Click on New Artifact Registry.
In the Registry Type dropdown, select Swift Registry (or Swift Package Registry).
Provide a Registry Name.
Optionally, add a Description and Labels for better organization.
Choose visibility between Public and Private.
Click Create Registry to finalize.
Configure an Upstream Proxy (Optional)
An upstream proxy allows your registry to fetch Swift packages from external sources when they are not available locally.
Create an upstream proxy
In the Artifact Registry module, select Upstream Proxy.
Choose Swift as the proxy type.
Enter an Upstream Proxy Name. Optionally add a Description and Labels.
Under Source, enter the Remote Registry URL for the upstream Swift Package Registry.
Under Authentication, select Anonymous (No credentials required) or Username and Password, depending on whether the upstream requires credentials.
Click Create Proxy to establish the connection.
Configure the upstream proxy in your registry
In the Artifact Registry module, select an existing Swift Artifact Registry.
Select the Configuration tab.
Under Advanced (Optional), select Configure Upstream.
Select from the list of compatible proxies to add them to your registry.
Click Save to save the configuration.
Swift Client Setup
Follow these instructions to configure SwiftPM, publish packages to Harness, and add them as dependencies in your projects.
Configure authentication
1. Generate Identity Token
An identity token serves as the credential for Swift Package Registry operations.
Generate an identity token from Setup Client on your Swift registry, or from your Harness account settings. Use it as <TOKEN> in the commands below.
2. Point SwiftPM at the Harness registry
Set the Swift Package Registry URL for your Harness registry:
Replace <ACCOUNT_ID> and <REGISTRY_NAME> with your account identifier and registry name. Use the URL shown in Setup Client if it differs.
3. Authenticate with your token
Use the same registry URL as in step 2 and the <TOKEN> from step 1. Copy the exact URL from Setup Client when it differs from the example host or path.
Publish a package
Publish a package version to your Harness Swift registry.
Basic publish:
With metadata (recommended):
With metadata and signatures (optional):
Replace <ARTIFACT_NAME> and <VERSION> with your package identity and semantic version. Prepare metadata.json and signing paths as required by your signing policy.
Install a package
1. Add a package dependency in Package.swift
Add a package-level dependency:
2. Add a target dependency
Reference the product from your library or executable target:
Replace <PRODUCT_NAME> with the product name exposed by the package.
3. Resolve dependencies
Fetch and resolve packages:
4. (Optional) Fetch packages from the registry instead of Git
If your Package.swift still references dependencies by Git URL, you can resolve using the registry:
To complete the in-product flow, click Done in Setup Client if you are following the in-product wizard.
Last updated
Was this helpful?