Ship a Swift command-line tool with Swift Package Manager
8 steps · about 2 h 5 min · Intermediate
- Create an executable package (tutorial, Swift.org, 20 min)
The official walkthrough from swift package init to running a tool with a dependency.
- Understand packages, targets and products (reference, Swift.org, 15 min)
Explains the Package.swift manifest and how SwiftPM resolves dependencies.
- Use the swift build, run and test commands (repo, GitHub, 20 min)
The SwiftPM repo README and docs cover creating packages, dependencies and release builds.
- See why ArgumentParser exists (article, Swift.org, 10 min)
The announcement shows declarative @Argument, @Option and @Flag properties producing help text.
- Add ArgumentParser to your package (repo, GitHub, 15 min)
README plus examples of subcommands, validation and shell completion.
- Look up commands, options and validation (reference, Swift Package Index, 20 min)
Hosted API docs for ParsableCommand, custom value types and error messages.
- Test the tool's logic with Swift Testing (repo, GitHub, 15 min)
The swift-testing repo shows @Test and #expect setup for package targets, giving clear failures for parsing logic.
- Install the toolchain on macOS, Linux or Windows (reference, Swift.org, 10 min)
Your CLI is cross-platform; this page shows the supported toolchains and install methods.