Add Swift Package Registry (SE-0292) configuration support#1626
Open
bdolewski wants to merge 1 commit into
Open
Add Swift Package Registry (SE-0292) configuration support#1626bdolewski wants to merge 1 commit into
bdolewski wants to merge 1 commit into
Conversation
Add a top-level `registries` key to project.yml. XcodeGen serializes it into the generated project's `project.xcworkspace/xcshareddata/swiftpm/configuration/registries.json`, the file SwiftPM and Xcode read to resolve registry (`.package(id:)`) dependencies. Xcode has no project-level (pbxproj) representation for registry packages, so this configuration file is the supported way to point a generated project at a registry. Dependencies themselves are still declared the existing way, by referencing a local Swift package whose Package.swift uses `.package(id:)`. Includes parsing and serialization tests, ProjectSpec docs, and a CHANGELOG entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Swift Package Registry (SE-0292) dependencies are resolved by SwiftPM through a
registries.jsonconfiguration file. Xcode has no project-level (pbxproj) representation for registry packages, so today there is no way to make an XcodeGen-generated project resolve.package(id:)dependencies from a registry without hand-placingregistries.jsonafter everyxcodegen generate(and re-placing it whenever the project is regenerated).This PR lets XcodeGen own that configuration.
What it does
Adds a top-level
registrieskey toproject.yml:XcodeGen serializes this into the generated project's
project.xcworkspace/xcshareddata/swiftpm/configuration/registries.jsonin SwiftPM's schema (sorted keys, unescaped slashes, emptyauthentication,version: 1). A registry value may be a bare URL string or a{ url, supportsAvailability }mapping.Dependencies themselves are still declared the existing, supported way: a local Swift package whose
Package.swiftuses.package(id:), referenced fromproject.ymlas alocal:package. XcodeGen does not write registry references into the.xcodeproj, because Xcode has no pbxproj representation for them. Authentication credentials are never written (configure them via.netrc/keychain as usual).Why not a pbxproj registry reference?
I verified on Xcode 26.5 that a project-level
XCRemoteSwiftPackageReferencewithkind = registryis silently ignored byxcodebuild(resolves zero packages, no error), consistent with Apple Feedback FB14699700 ("not supported in Xcode directly"). The supported mechanism isregistries.jsonplus SwiftPM resolution, which is what this PR generates.Validation
swift testpasses, including new parsing and serialization tests.https://tuist.dev/api/registry/swift) builds with vanillaxcodebuild build -destination 'generic/platform=iOS Simulator'(BUILD SUCCEEDED); the dependency is fetched from the registry, not from git.Changes
registriesproject spec model with parsing and serialization.FileWriterwritesregistries.jsonafter the project is written (no-op when unset or unchanged).Docs/ProjectSpec.md) and a CHANGELOG entry.Notes
registriesis optional.mirrors.jsongeneration; SCM-to-registry transformation scheme/build settings.This change was developed with assistance from Claude Code (Anthropic). Happy to adjust the
registrieskey name or shape to your preference.🤖 Generated with Claude Code