About this project

SwiftFormat is a code library and command-line tool for reformatting Swift code on macOS, Linux or Windows. Beyond simple whitespace adjustment, it can insert or remove implicit `self`, remove redundant parentheses, and correct many other deviations from standard Swift idioms. The project's stated motivation is that agreeing on a common coding style helps collaboration, but enforcing it manually is tedious and error-prone. An automated formatter lets teams focus on code behavior rather than presentation. Ways to use it: - Command-line tool, run manually or as part of a toolchain - Xcode Source Editor Extension, invoked via the Editor > SwiftFormat menu - Xcode build phase, running on each build - Git pre-commit hook, formatting changed files before commit - Swift Package Manager command plugin (Swift 5.6+) - Integrations for VSCode (via Run on Save), Sublime Text, and Nova - GitHub Actions, Danger on CI, Bazel, Docker, and AppleScript Installation options include Homebrew (`brew install swiftformat`), Mint, Nix/nixpkgs, CocoaPods, a binary artifactbundle in Package.swift, or building manually with `swift build -c release`. The Xcode extension is available as a Homebrew cask or from GitHub Releases. Basic usage is `swiftformat .` to format Swift files in the current directory. The README warns that this overwrites files in place, so users should commit changes first; `--infer-options` can suggest settings matching an existing project style. Standard input/output piping is supported, including `--stdin-path` to supply file location context. Configuration covers options, rules, Swift version, a `.swiftformat` config file, globs, linting mode, error codes, caching, file headers, and Markdown formatting. The README also includes an FAQ, known issues, a tip jar, and credits. The project is MIT licensed.