A modern, robust, and fully automated template for building native macOS command-line tools in Swift. This template was extracted from the architectural patterns established in richclip.
- Copier Setup: Fully configured for Copier, meaning you can generate new projects with dynamic variables and update them later as the template evolves.
- Architecture: Pre-configured with Apple's
swift-argument-parserfor declarative, type-safe CLI routing and help menu generation. - System Testing: Includes a boilerplate
XCTestCasethat actually compiles the binary and testsstdoutandexit codesviaProcess(). - Toolchain Parity: Uses
miseto strictly pinswift,just, andswiftformatversions, ensuring local development is identical to CI. - Continuous Integration: GitHub Actions workflow that formats, lints, builds, and tests on every push and PR.
- Automated Release Pipeline: Pre-configured with
release-pleaseto manage version strings, changelogs, and GitHub Releases based purely on Conventional Commits. - Universal Binaries: Automatically compiles "fat" binaries (Intel + Apple Silicon) for frictionless distribution.
- Navigate to the directory where you want to create your new project.
- Run the
copiercommand, pointing it to this template directory (or the GitHub repo if hosted remotely):uxv copier@latest copy path/to/swift-project-template my-new-cli
- Answer the prompts for your project name, description, and GitHub username.
- Navigate into your new project:
cd my-new-cli
Once generated, the template will automatically initialize a Git repository and make an initial commit.
To sync your generated configuration to GitHub (including descriptions, topics, and branch protections), simply run:
just github_setupYou can immediately start developing using the standard Justfile recipes:
just build # Compiles the Swift binary
just test # Runs the XCTest suite (unit & system tests)
just fmt # Auto-formats your code using swiftformat
just lint # Checks for formatting violations
just run # Executes your CLIBecause of release-please, simply use Conventional Commits (feat:, fix:, docs:) and push to master. The GitHub Actions pipeline will automatically handle compiling the Universal Binary and publishing the release!