finds.dev← search

// the find

nicklockwood/SwiftFormat

★ 8,857 · Swift · MIT · updated Jul 2026

A command-line tool and Xcode Extension for formatting Swift code

SwiftFormat is a code formatter for Swift that goes further than whitespace: it can insert or remove implicit `self`, strip redundant parentheses, enforce trailing commas, and apply 50+ other opinionated transforms. It targets any Swift developer or team that wants formatting enforced automatically rather than debated in code review.

The rule set is genuinely broad — things like `redundantSelf`, `isEmpty`, and `hoistPatternLet` go well beyond what most formatters attempt, catching real style inconsistencies not just indentation. Integration options cover every realistic workflow: CLI, Xcode extension, SPM plugin, build phase, pre-commit hook, GitHub Actions, and Docker, so teams can enforce it wherever they trust. The `--infer-options` flag is a practical touch: point it at an existing codebase and it reverse-engineers a config that matches current style, which makes onboarding onto legacy codebases much less painful. The `Snapshots/` directory is used as regression test fixtures against real-world repos, which catches edge cases that unit tests on synthetic code miss.

The Xcode source editor extension can't read per-project `.swiftformat` files automatically — you have to manually import and re-import the config every time it changes, which means in practice most Xcode plugin users just run with global settings and silently diverge from the project config. The `--disable all` plus explicit enable pattern is the right escape hatch for locking down new rule opt-ins, but it's easy to miss: teams that don't know about it will pick up new rules on every SwiftFormat upgrade, causing unexpected diffs in CI. There's no semantic understanding of Swift — rules like `redundantSelf` can misfire in contexts involving property wrappers or closures with captures, and the workaround is a per-line disable comment rather than a fix. Windows support exists but is clearly a second-class citizen: no Xcode extension, no Homebrew, build-from-source only, and the WiX installer in `Platforms/Windows/` looks unmaintained.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →