Version 1.0.0: SwiftPM Plugin Support #420
Merged
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.
Breaking changes:
cartonCLI is now slimmed down to be a SwiftPM Plugin.This means that you can now use
cartonby just declaring it as a dependency in yourPackage.swiftfile.This change requires Swift 5.9.2's SwiftPM to make cross-compilation work well, so Swift 5.9.1 or earlier is no longer supported.
Each
cartonsubcommand is now split into a separate SwiftPM plugin.carton devswift run carton devcarton testswift run carton testcarton bundleswift run carton bundleAlso
cartonno longer supports the following features:carton initcommand (useswift package init --type executableinstead)Internal changes:
cartonno longer has to be updated when SwiftPM is updated (hopefully).Our new SwiftPM plugin oriented architecture is illustrated in the following diagram:
sequenceDiagram participant SwiftRunCarton as swift run carton participant SwiftPM participant CartonDevPlugin as carton-dev Plugin participant CartonFrontend SwiftRunCarton->>SwiftPM: exec SwiftPM->>CartonDevPlugin: spawn CartonDevPlugin->>SwiftPM: Build product SwiftPM->>CartonDevPlugin: Build artifacts CartonDevPlugin->>CartonFrontend: spawn note right of CartonDevPlugin: Establish IPC CartonFrontend->>CartonDevPlugin: File changed CartonDevPlugin->>SwiftPM: Build product SwiftPM->>CartonDevPlugin: Build artifacts CartonDevPlugin->>CartonFrontend: Reload browsersRationale on the design decision
Why not be a simple SwiftPM Plugin? Why use
swift run?swift run cartonis a thin wrapper of SwiftPM Plugin to work around some SwiftPM Plugin limitations for the following purposes:express this requirement in the package manifest
{package-name}PackageTestsproduct before running plugin processThis
swift runwrapper should be eventually removed once SwiftPM provides a way to express those requirements.How does this affect Swift SDK support?
This design gives us better integration with SwiftPM build system and you will get more control over your build.
If you installed Swift SDK and Swift 5.9.2 from https://www.swift.org/download, you can use the SDK by directly invoking SwiftPM Plugin like below:
Note that if you use SwiftPM Plugin directly, you need to ensure that the
swiftcommand is set up by yourself and teach SwiftPM for some permission options.