0Pricing
Swift Academy · Lesson

SwiftFormat / SwiftLint basics

Set up SwiftFormat to auto-format code and SwiftLint to flag style issues. Run locally and in CI with simple, beginner-friendly rules.

Why format & lint?

Goal: Keep code consistent and readable.

  • SwiftFormat → auto-format source
  • SwiftLint → flag style issues
  • Run locally and in CI for steady quality

SwiftFormat: getting started

SwiftFormat rewrites files to a uniform style. Keep a .swiftformat in the repo and run it before commits.

// Install & run (examples):
//   mint install nicklockwood/SwiftFormat     // via Mint
//   swiftformat .                             // format repo
//   swiftformat Sources --config .swiftformat // use config file
//
// Minimal .swiftformat (put in repo root):
// --ifdef no
// --wrapcollections before-first
// --maxwidth 100
print("SwiftFormat: run to auto-format code consistently")

All lessons in this course

  1. SwiftFormat / SwiftLint basics
  2. Style guide, API design guidelines
  3. Documenting code (DocC intro)
← Back to Swift Academy