Repository navigation
Let SwiftPM use prebuilt swift-syntax for CodableKitMacros - #31
Merged
Merged
Conversation
SwiftPM only substitutes prebuilt swift-syntax when every macro module depends solely on host-only modules. CodableKitMacros depended on CodableKitCore, which clients also link through CodableKit, so the whole graph fell back to compiling swift-syntax from source. Compile the shared option definitions into the macro through a SharedCore symlink instead. A downstream cold release build dropped from 1,136 s to 59 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the macro dependency restructuring.
No open issues 🎉
What changed in this PR
This PR restructures how CodableKitMacros consumes shared option definitions so SwiftPM can use prebuilt swift-syntax, without changing CodableKit’s public API.
Changes:
- Removes the macro target’s dependency on the runtime-linked
CodableKitCoremodule. - Reuses shared definitions through a symlink, with renamed source files to avoid basename collisions.
- Removes
CodableKitCoreimports from macro implementation files.
| File | Description |
|---|---|
Sources/CodableKitMacros/CodeGenCore.swift |
Removes the Core module import from code generation. |
Sources/CodableKitMacros/CodableOptions.swift |
Uses locally compiled shared macro options. |
Sources/CodableKitMacros/CodableMacro.swift |
Removes the Core module import from macro implementation. |
Sources/CodableKitMacros/CodableKeyOptions.swift |
Uses locally compiled shared key options. |
Sources/CodableKitCore/CodableOptionsDefinition.swift |
Renames shared macro option definitions to avoid filename collisions. |
Sources/CodableKitCore/CodableKeyOptionsDefinition.swift |
Renames shared key option definitions to avoid filename collisions. |
Package.swift |
Removes the macro-to-Core dependency and documents the prebuilt rationale. |
Review effort: Balanced
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.
SwiftPM substitutes prebuilt swift-syntax only when every macro module depends solely on host-only modules (
handlePrebuiltsin ModulesGraph+Loading).CodableKitMacrosdepended onCodableKitCore, which clients also link throughCodableKit. That made Core an all-platform module, and SwiftPM fell back to building swift-syntax from source for the whole graph.The macro now compiles the shared option definitions through the symlink
Sources/CodableKitMacros/SharedCore -> ../CodableKitCore, so there is still one source of truth. Core files were renamed to avoid basename clashes. The public API is unchanged.Measured downstream (Tiamat, cold
swift build -c releaseon macOS 26.7.1 / Swift 6.4): 1,136 s → 59 s, with no swift-syntax compilation. All 367 package tests pass locally.🤖 Generated with Claude Code