Docs menuSwift Package Registry

Swift Package Registry

LPM.dev Registry implements the SE-0292 Swift Package Registry API. Swift Package Manager (SPM) resolves LPM.dev Registry packages natively. This includes versions, manifests, archives, checksums, and signatures.

Install a Swift package

Use the LPM CLI to install a Swift package:

lpm login
lpm install @lpm.dev/acme.swift-logger

A Free Swift release does not need an account. Anyone can list its versions, read its manifests, and download its archives. If the package is Private, Pool, or Marketplace, run lpm login first. For a Free release, lpm install also sets up package signing, and SPM verifies the signature.

If the project or the machine does not have the Swift registry setup, lpm install runs it automatically. Then it resolves the package and updates the project for its structure.

Projects with Package.swift

If the project has a Package.swift, the LPM CLI does these steps:

  1. Resolves the requested LPM.dev Registry package and product.
  2. Adds the SE-0292 package identity to dependencies.
  3. Adds the product to the selected target.
  4. Runs swift package resolve.
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
    name: "MyApp",
    dependencies: [
        .package(id: "lpmdev.acme_swift-logger", from: "1.0.0"),
    ],
    targets: [
        .target(
            name: "MyApp",
            dependencies: [
                .product(
                    name: "SwiftLogger",
                    package: "lpmdev.acme_swift-logger"
                ),
            ]
        ),
    ]
)

If the manifest has more than one eligible target, the LPM CLI asks which target gets the product. With --yes, it selects the first eligible target.

Xcode-only projects

If the project has an .xcodeproj but no Package.swift at its root, the LPM CLI does these steps:

  1. Creates a local package at Packages/LPMDependencies to hold the dependencies.
  2. Links that package into the Xcode project.
  3. Adds the LPM.dev Registry package to it.
  4. Resolves the package with SPM.

SPM manages these dependencies. The application does not need to become a Swift package.

The LPM CLI install reference describes all project detection and manifest edits.

Explicit setup and repair

lpm install runs the setup when the project needs it. To set up a machine without an install, run this command:

lpm swift-registry

If a certificate rotation needs a new local certificate, add --force. The flag replaces the certificate even if its bytes match the current one:

lpm swift-registry --force

The setup does these steps:

  1. Points the SPM lpmdev scope to https://lpm.dev/api/swift-registry.
  2. Passes the current LPM.dev Registry token to SPM.
  3. Downloads the CMS signing certificate of LPM.dev Registry.
  4. Writes the SPM signing trust policy for the LPM.dev Registry host.

If the scope, certificate, or trust policy step fails, the setup stops. If no token is available, lpm swift-registry skips the login and shows a warning. If a login or a session refresh fails, the setup stops. Requests for protected packages need a valid credential. If all requested releases allow anonymous access, lpm install skips the login.

The LPM CLI swift-registry reference describes the flags, JSON output, certificate rotation, and local configuration paths.

Package identity

LPM.dev Registry names map to SE-0292 identities:

LPM.dev Registry nameSE-0292 identity
@lpm.dev/acme.swift-loggerlpmdev.acme_swift-logger
@lpm.dev/design-team.tokenslpmdev.design-team_tokens

The mapping has three parts:

  • The @lpm.dev/ scope becomes lpmdev.
  • The dot between the owner and package becomes an underscore.
  • Hyphens inside the owner or package name stay unchanged.

The LPM CLI does this mapping automatically.

Package signing

LPM.dev Registry signs each Swift source archive with a detached CMS signature. The signature uses ECDSA P-256 and SHA-256. SPM verifies the signature against the downloaded archive.

If the signed archive changes, the signature verification fails. The HTTPS connection to LPM.dev Registry authenticates the server that sends the certificate and the package.

The LPM.dev Registry certificate is self-signed. No system certificate authority signs it. The setup writes a silentAllow rule for the LPM.dev Registry host only. With this rule, SPM accepts the signer and still runs the CMS integrity check. For all other registries, the setup makes error the default policy for unsigned packages and untrusted certificates.

The signer is LPM.dev Registry. The package author does not sign the archive. The signature proves that the archive came from LPM.dev Registry. It does not prove which author made the archive.

Transitive dependencies

Swift packages can depend on other LPM.dev Registry packages and on Git-hosted Swift packages. SPM resolves both in the same dependency graph:

MyApp
└── @lpm.dev/acme.swift-network
    ├── @lpm.dev/acme.swift-logger
    └── swift-nio

Use lpm install to add a Swift library as a dependency. Do not use lpm add for Swift dependencies. It copies source files into the project.

Publish a Swift package

A Swift package needs two files at its root to publish. package.json gives the LPM.dev Registry name and version. Package.swift is the Swift manifest:

{
  "name": "@lpm.dev/acme.swift-logger",
  "version": "1.0.0"
}
lpm publish --check
lpm publish

The LPM CLI finds Package.swift automatically. It reads the products, targets, platforms, dependencies, and tools version with the Swift toolchain on your machine. You do not need to set lpm.config.json > ecosystem.

After the upload, LPM.dev Registry prepares the release. It evaluates every root manifest with Swift in an isolated sandbox and checks the result against the uploaded files. Then it creates the SE-0292 source archive, records its checksum, and signs the archive and the manifests for SPM clients. Nobody can install the release until this finishes, the package owners included. It usually takes less than a minute. The package page shows its owners that the release is being prepared. Publish packages describes private releases and reviewed public releases.

Swift tools compatibility

LPM.dev Registry evaluates Package.swift with Swift 6.4.2. It also accepts older compatible manifests, such as tools versions 5.1, 5.10, and 6.0. You do not need to raise the tools requirement of your package to 6.4.

The swift-tools-version header gives the minimum tools version that can read the manifest. It is separate from the release version of the package. LPM.dev Registry keeps the header as you wrote it.

The manifest evaluation does not build or test the package sources. Before you publish, test the package on each supported platform and toolchain.

Rejected releases

LPM.dev Registry rejects a Swift release in these cases:

  • A manifest needs newer tools than Swift 6.4.2. Lower the declared version only if the package works with the older tools.
  • Swift cannot evaluate a manifest. Check that swift package dump-package succeeds for every manifest.
  • Swift does not finish evaluating the manifests within 30 seconds, on each of five attempts.
  • The release targets the Pool or the Marketplace, and that distribution cannot include one of its Swift dependencies.
  • LPM.dev Registry could not prepare the release within a day.

LPM.dev Registry removes a rejected release's files, frees the storage they used, and tells the package owners why on the package page and by email. Nobody ever installed a rejected release, so you can publish the same version again, and the new upload replaces it.

See also