
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
- 20 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
How to get it
- 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 swiftlintInstall with Mint
mint install realm/SwiftLint - 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
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
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| SwiftLint (this) | 19.8k | Dev tool | beginner | 20 days ago | iOS and macOS developers who want consistent Swift style across a team |
| static-analysis | 14.9k | Curated list | beginner | 4 days ago | Developers looking for a linter or analyzer for a specific language |
| infer | 15.7k | Dev tool | intermediate | 4 days ago | Developers working on Java, C, C++, or Objective-C codebases |
| super-linter | 10.6k | Dev tool | beginner | 6 days ago | Teams that want automated code checks on GitHub pull requests |
| ruff | 50.4k | CLI | beginner | 4 days ago | Python developers who want one tool for linting and formatting |
| ast-grep | 16.4k | CLI | beginner | 4 days ago | Developers 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.