This is a motivating use case and a request for feedback, not an Evolution proposal for a new registry protocol, version ordering rule, or dependency override API.
Motivation
Swift packages sometimes contain substantial development-only content, such as test fixtures, golden images, benchmarks, or unrelated projects in a monorepo. These files are useful to package maintainers but may be unnecessary for applications consuming the package.
Downloading a source archive instead of cloning Git history (as explored in PR #9870) can reduce acquisition overhead, but it does not eliminate unnecessary files in the selected revision. A slim distribution addresses this separate problem by changing which files are included in the published archive.
One possible approach is to distribute a smaller source archive through a Swift Package Registry, without requiring upstream maintainers to change their repositories. An organization could derive and validate such an archive from a known upstream release, then publish it under a distinct immutable version identifier.
For example, an internal registry could publish 1.2.0+corp.0 and later 1.2.0+corp.1, both derived from upstream 1.2.0. A final application could explicitly select the desired distribution using .exact("1.2.0+corp.1").
This is another practical use case for PR #10410, which addresses exact version matching with build metadata. If this workflow is viable with just #10410 and existing registry features, that would be an ideal outcome, no new Evolution proposal needed.
Proposed workflow
Suppose an organization maintains a distribution pipeline for an upstream Git package:
Upstream Git: Library 1.2.0
|
v
Internal packaging pipeline (trim & validate)
|
+--> 1.2.0+corp.0
+--> 1.2.0+corp.1 # Packaging correction
|
v
Final application
The division of responsibilities is straightforward:
- Distributor / internal registry owns: source trimming, package validation for supported targets, provenance, and publishing immutable releases.
- SwiftPM owns: resolving dependency constraints, fetching the requested immutable archive, and applying configured integrity checks. SwiftPM does not judge source equivalence or decide which files to omit.
This workflow assumes that a registry can publish a valid source archive derived from an upstream release without requiring byte-for-byte equivalence to the corresponding Git checkout. The distributor is responsible for validating the reduced archive, including any manifest-referenced files needed by supported consumers.
For an application using a SwiftPM root manifest, the dependency declarations could look like this:
// Transitive dependencies (published upstream):
.package(url: "https://github.com/vendor/Library.git", from: "1.2.0")
// Final application (under consumer control):
.package(id: "internal.Library", exact: "1.2.0+corp.1")
1.2.0+corp.0 and 1.2.0+corp.1 share identical SemVer precedence, so both satisfy transitive version ranges admitting 1.2.0. However, when the final application requires .exact("1.2.0+corp.1"), a different immutable archive must not be selected.
This is not a general dependency override mechanism: the root's exact requirement must still satisfy all transitive constraints. An incompatible range or a transitive exact requirement for a different identifier would remain a conflict.
An important prerequisite: SwiftPM must successfully unify the upstream SCM dependency and the registry package into a single logical identity, for example through --replace-scm-with-registry. Whether this reliably works for the described dependency graph needs to be verified. Integration with Xcode-managed dependencies may also require separate validation.
Why PR #10410 matters
Under SemVer 2.0.0, build metadata must be ignored when comparing precedence. However, when a consumer explicitly requests an exact identifier, the complete version identifier distinguishes which immutable registry release was requested.
Today, SwiftPM's existing .exact(...) requirement can lose this distinction and match another published identifier at the same precedence position, potentially selecting the wrong archive.
The history of this fix is directly relevant:
- I proposed SE-0534 , an opt-in
.exactLiteral(...)API. - The Ecosystem Steering Group rejected that additional API, agreeing that the existing
.exact(...)behavior is a bug that should be fixed in place. - SwiftPM PR #10410 implements this fix across resolver operations, downloads, and
Package.resolved.
Under the proposed #10410 behavior:
SemVer precedence:
1.2.0 == 1.2.0+corp.0 == 1.2.0+corp.1
Complete parsed version-identifier identity:
1.2.0 != 1.2.0+corp.0 != 1.2.0+corp.1
Final app requirement:
.exact("1.2.0+corp.1") -> selects only 1.2.0+corp.1
Transitive range requirement:
from: "1.2.0" -> also admits 1.2.0+corp.1
If the distributor discovers a packaging error in 1.2.0+corp.0, it publishes a new immutable release, 1.2.0+corp.1. The application explicitly updates its .exact pin.
There is no need for corp.1 to sort after corp.0 in precedence, nor does this require a new override API or a separate distribution-revision axis in SwiftPM.
The essential requirement is that an explicitly selected version identifier consistently identifies the same immutable release throughout resolution, downloading, and subsequent builds. This is why #10410 matters beyond the semantics of a single version comparison.
Questions for maintainers and the community
- Use case alignment: Is this a reasonable use case for #10410? Specifically, selecting an immutable, derived source distribution by its complete version identifier while retaining ordinary SemVer range compatibility.
- SCM-to-registry identity mapping: Can existing SCM-to-registry identity mapping support this workflow? For example, when transitive dependencies reference the upstream Git URL but the final application pins a registry version.
- Boundary conditions: Are there other SwiftPM or registry constraints that would prevent this workflow, assuming the distributor independently handles packaging, validation, and provenance?