Cloud customer?
Start for Free >
Upgrade in MyJFrog >
What's New in Cloud >





Overview

From JFrog Artifactory version 7.41.4, Artifactory provides full support for managing Swift packages. Aggregating multiple Swift registries under a virtual repository Artifactory provides access to all your Swift packages through a single URL for both upload and download.

Swift Version Support

Artifactory supports Swift version 5.7.1 and above.

Did you know?

Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

The Swift Package Manager:  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.

Swift repository (Catalog):  https://swiftpackageregistry.com/ is a catalog of Git repositories, each containing a Swift package. The Swift package manager is an open-source project for managing the distribution of source code, aimed at making it easy to share code and reuse others’ code. The tool compiles and links Swift packages, managing dependencies, versioning, and supporting flexible distribution and collaboration models. For more information, see Swift Package Manager.

As a fully-fledged Swift registry on top of its capabilities for advanced artifact management, Artifactory's support for Swift provides:

  • Calculation of Metadata for Swift packages hosted in Artifactory's local repositories.
  • Access to remote registries through Remote Repositories which provide the usual proxy and caching functionality.
  • The ability to access multiple Swift registries from a single URL by aggregating them under a Virtual Repository. This overcomes the limitation of the Swift client which can only access a single registry at a time.
  • Compatibility with the Swift command line tool to deploy and remove packages and more.
  • Support for validating remote Swift repository metadata.
Page Contents

 


Swift Repository Structure

The Swift package structure is as follows.


├── Package.swift
├── README.md
├── Sources

│      └─ Hello
│       └── hello.swift
└── Tests
   
       └─ HelloTests
        └── helloTests.swift
       └─ LinuxMain.swift


Deployment Structure

All deployment of Swift packages into Artifactory can be deployed under the following structures:

  • <SCOPE>/<NAME>/<NAME>-<VERSION>.zip structure.
  • <scope>/<name>/<version>: Based on the following Swift Publish API.

Note that the packages have to be deployed according this structure, otherwise they will not be included in the index file. 


Setting up a Swift Registry

You can set up the following repository types:

Follow the steps according to each repository type below.
You can download packages from a local, remote, or virtual Swift registry.

Setting up a Local Repository

Local repositories enable you to deploy Swift (.swift) packages. Artifactory calculates the metadata for all packages and indexes them to allow users to download these packages through the Swift client. 

Prerequisite

Artifactory allows you to define any layout for your Swift registries. In order to upload packages according to your custom layout, you need to package your Swift files using the Swift source archive. This creates the .zip file for your package which you can then upload to any path within your local Swift repository.

To create a Swift local repository:

  1. Navigate to the Administration module, go to Repositories | Repositories | Local New Local Repository.
  2. Select Swift as the Package Type.

Setting up a Remote Repository

Swift Remote repositories are currently only supported as Smart Remote repositories. Artifactory is the only Swift registry available today, so you would not be able to proxy other remote resources. 

A Remote Repository defined in Artifactory serves as a caching proxy for a registry managed at a remote URL. Artifacts (such as .zip files) requested from a remote repository are cached on demand. You can remove downloaded artifacts from the remote repository cache, however, you can not manually deploy artifacts to a remote swift registry. 

Remote Repositories enable you to proxy and cache Swift packages.

To define a remote repository to proxy a remote swift registry:

  1. In the Administration module, under Repositories | Repositories | Remote, click New Remote Repository.
  2. In the New Remote Repository page:
    1. Set the Package Type to Swift and the Repository Key value.
    2. Specify the URL to the remote registry in the URL field.
    3. Click Save & Finish.

Setting up a Virtual Repository

A Virtual Repository defined in Artifactory aggregates packages from both local and remote repositories.

This allows you to access both locally hosted Swift packages and remote proxied Swift repositories from a single URL defined for the Virtual Repository.

To define a virtual Swift repository, do the following:

  1. In the Administration module, under Repositories | Repositories | Virtual, click New Virtual Repository.
  2. In the New Virtual Repository dialog, set the Package Type to Swift
  3. Select the underlying local and remote Swift registries to include in the Basic settings tab.
  4. Click Save & Finish to create the repository.

Configuring the Swift Client to work Opposite Artifactory

To use Artifactory with your Swift CLI, you will need to 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.

Searching for Swift Packages

You can search for Swift Packages, using the Artifact Package Search.


Re-Indexing 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 will also reindex 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. Requires Admin privileges.

To reindex a Swift repository through the REST API refer to the following REST API.

Calculate a Swift Index

Description: Calculates a Swift index for the specified repository.

Notes: Requires Artifactory Pro.

Security: Requires a valid admin user. 

Usage: POST /api/swift/{repoKey}/reindex

Produces: application/text

Since: 7.39.4

Sample Output:

POST /api/swift/swift-local/reindex
 
Reindexing of Swift repository swift-local was scheduled to run.

  • No labels
Copyright © 2022 JFrog Ltd.