Skip to content

Add Swift Package Registry support#15

Merged
albertodebortoli merged 3 commits intomainfrom
swift-package-registry-support
Jun 9, 2025
Merged

Add Swift Package Registry support#15
albertodebortoli merged 3 commits intomainfrom
swift-package-registry-support

Conversation

@albertodebortoli
Copy link
Copy Markdown
Member

@albertodebortoli albertodebortoli commented Jun 6, 2025

These changes allow the generation of Package.swift files when using a Swift Registry.

The dependency in the dependencies file should have an identifier value. The url value is not needed when using a registry but it's kept for backward compatibility (it would also come handy for documentation purposes to re).

dependencies:
  - name: RemoteDependency
    identifier: acme.RemoteDependency
    url: https://github.com/RemoteDependency
    version: 1.0.0

The Spec file will have to specify which remote dependency is referenced from the target dependencies to resolve the correct value for the package parameter (the identifier) in the product definition (.product(name: "RemoteDependency", package: "acme.RemoteDependency")). We cannot just rely on the name value since it might differ from what used in the dependencies file, as expressed in the test using the _SDK suffix.

name: Registry
products:
  - name: Registry
    productType: library
    targets:
      - Target
localDependencies: []
remoteDependencies:
  - name: RemoteDependency
targets:
  - name: Target
    targetType: target
    dependencies:
      - name: RemoteDependency_SDK
        dependency: RemoteDependency
    sourcesPath: Framework/Sources
    resourcesPath: Resources

Reflecting as follows in the Package.swift file:

...
let package = Package(
    ...
    dependencies: [
        .package(
            id: "acme.RemoteDependency",
            exact: "2.0.0"
        ),
    ],
    targets: [
        .target(
            name: "Target",
            dependencies: [
                .product(name: "RemoteDependency_SDK", package: "acme.RemoteDependency")
            ],
            ...
        )
    ]
)

@albertodebortoli albertodebortoli force-pushed the swift-package-registry-support branch from 84f0c59 to ab98ddd Compare June 8, 2025 11:24
@albertodebortoli albertodebortoli force-pushed the swift-package-registry-support branch from ab98ddd to 62fe9c0 Compare June 8, 2025 11:44
@albertodebortoli albertodebortoli marked this pull request as ready for review June 8, 2025 11:59
@@ -0,0 +1,55 @@
// swift-tools-version: 6.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of the scope, 6.1 is available

@albertodebortoli albertodebortoli merged commit ca8abdb into main Jun 9, 2025
2 checks passed
@albertodebortoli albertodebortoli deleted the swift-package-registry-support branch June 9, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants