A while ago, I blogged that I started using Swimat to format my Swift code. But recently, I stumbled upon SwiftFormat (because I'm using some old Objective-C packages from Nick Lockwood and browsed his other projects), and now I'm using that.

It's an easy install using brew (also Cocoapods and Swift Package Manager), and there's both a command-line tool and (like Swimat) an Xcode extension. Once you've downloaded them, if you double-click the extension, it'll display instructions for activating it in Xcode.

Namely, go into System Preferences->Extensions and enable SwiftFormat as an Xcode extension.

After that, when you start up Xcode, you'll see some options.

And you can configure Xcode to run SwiftFormat as a build process, but I prefer to just manually run the command-line tool in the shell on my entire project (apparently my Talk Dim Sum app has 127 Swift files) and check my git diffs to see what changed.

It's faster that way!