Skip to content

iloveitaly/swift-project-template

Repository files navigation

Swift CLI Project Template

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.

What's Included?

  • 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-parser for declarative, type-safe CLI routing and help menu generation.
  • System Testing: Includes a boilerplate XCTestCase that actually compiles the binary and tests stdout and exit codes via Process().
  • Toolchain Parity: Uses mise to strictly pin swift, just, and swiftformat versions, 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-please to manage version strings, changelogs, and GitHub Releases based purely on Conventional Commits.
  • Universal Binaries: Automatically compiles "fat" binaries (Intel + Apple Silicon) for frictionless distribution.

Prerequisites

How to use

  1. Navigate to the directory where you want to create your new project.
  2. Run the copier command, 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
  3. Answer the prompts for your project name, description, and GitHub username.
  4. Navigate into your new project:
    cd my-new-cli

Initializing the Repository

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_setup

Developing

You 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 CLI

Because 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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages