Skip to content

SwiftLint

A command-line tool that checks Swift code against common style rules.

Stars
19.8k
Forks
2.3k
Licence
MIT
Language
Swift
Last update
21 days ago
Type
Dev tool

What it is

SwiftLint is a tool that reads Swift source code and reports places where it breaks widely accepted style and convention rules. It can also automatically fix some of those issues when asked. Teams use it to keep code consistent without relying only on manual code review.

  • Flag style violations directly in the Xcode editor
  • Run lint checks as a build tool plugin on each target
  • Run SwiftLint from the command line on a project directory
  • Use the --fix or --autocorrect options to correct some violations automatically

Great for

  • iOS and macOS developers who want consistent Swift style across a team
  • Teams that want style checks to run automatically in builds or Xcode
  • Swift package authors who want linting through Swift Package Manager plugins

Not ideal for

  • People who only want to run Swift code and have no interest in style rules, since it only checks style and conventions
  • Projects with code that does not compile, because the README warns that SwiftLint is designed for valid, compilable source and results can be confusing otherwise
Step-by-step guide: how to use SwiftLintInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Swift toolchain or Xcode for building or plugin use · Homebrew, CocoaPods, Mint, or Swift Package Manager, depending on chosen install route

    Install with Homebrew

    brew install swiftlint

    Install with Mint

    mint install realm/SwiftLint
  2. 2

    Run it

    • Install SwiftLint using one of the methods in the README, such as Homebrew.
    • Open a Swift project directory in a terminal.
    • Run swiftlint from that directory to see reported violations.
    • Optionally add the build tool plugin to your target or Xcode project for automatic checks.
  3. 3

    Get the most out of it

    • Add the SwiftLintBuildToolPlugin to each target you want linted, since plugins run per target
    • Use the topmost config file in your package or project so the plugin finds it automatically
    • Use the swift package plugin swiftlint command to run SwiftLint from the command line through Swift Package Manager
    • Consider the SwiftLintPlugins repository for Swift Package Manager integration, as the README recommends it

Downloads

Strengths

  • Rules are based on SwiftSyntax and widely accepted Swift community conventions
  • Available through several install routes, including Homebrew, Swift Package Manager, CocoaPods, Mint, and Bazel
  • Released under the permissive MIT license

Trade-offs

  • Some rules still depend on Clang and SourceKit, so behavior may depend on the toolchain
  • Automatic fixes are risky on code that does not compile, as the README cautions
  • Using plugins directly from the main repository has drawbacks; the README recommends a separate plugins repository

How it compares

ProjectStarsTypeLevelUpdatedBest for
SwiftLint (this)19.8kDev toolbeginner21 days agoiOS and macOS developers who want consistent Swift style across a team
static-analysis14.9kCurated listbeginner5 days agoDevelopers looking for a linter or analyzer for a specific language
infer15.7kDev toolintermediate4 days agoDevelopers working on Java, C, C++, or Objective-C codebases
super-linter10.6kDev toolbeginner6 days agoTeams that want automated code checks on GitHub pull requests
ruff50.4kCLIbeginner4 days agoPython developers who want one tool for linting and formatting
ast-grep16.4kCLIbeginner4 days agoDevelopers who want grep-like searching that understands code structure

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.