A Java static analysis tool that checks source code against a coding standard, configurable via XML and run from the command line, Ant, or Maven.
realm/SwiftLint
A linter that enforces Swift style and conventions, with over 200 rules that can be configured per project.
- Stars
- 19,779
- Forks
- 2,338
- Open issues
- 535
- Last commit
- 2 days ago
What is it?
SwiftLint checks Swift source code against a set of style and convention rules, reporting violations as warnings or errors in the terminal or directly in Xcode. Most rules are built on SwiftSyntax, and a smaller set uses Clang and SourceKit to access type information. Rules are turned on or off through a .swiftlint.yml file, where you can also tune thresholds such as line length and type body length.
For files with violations that have automatic fixes, the --fix option rewrites them in place. The separate analyze command runs rules that use the full type-checked AST, though these are slower and opt-in. Custom rules can be defined with regular expressions in the configuration file, or written in Swift.
SwiftLint can be installed through Homebrew, CocoaPods, Mint, Bazel, or Swift Package Manager, and it runs in CI via Docker, fastlane, or a pre-commit hook.
Key features
- 01Over 200 built-in style and convention rules for Swift code
- 02Xcode integration that shows violations inline in the editor
- 03Automatic correction of fixable violations with --fix
- 04Type-aware analyze command for rules that need the full AST
- 05Custom regex-based rules and parent/child config file merging
Use cases
- Enforcing a shared Swift style guide across a team's iOS or macOS projects
- Running lint checks in CI pipelines through Docker, fastlane, or pre-commit hooks
- Gradually cleaning up legacy code with baselines and auto-correction
Quick start
- 1
Install SwiftLint with Homebrew
brew install swiftlint - 2
Run SwiftLint in your project directory
swiftlint
Things to know
- Some rules rely on Clang and SourceKit for type information, and SwiftLint is designed to analyze compilable code only.
- Using --fix on non-compiling code can produce confusing results.
In collections
Topics
FAQ
- What is SwiftLint?
- A linter that enforces Swift style and conventions, with over 200 rules that can be configured per project. SwiftLint checks Swift source code against a set of style and convention rules, reporting violations as warnings or errors in the terminal or directly in Xcode. Most rules are built on SwiftSyntax, and a smaller set uses Clang and SourceKit to access type information. Rules are turned on or off through a .swiftlint.yml file, where you can also tune thresholds such as line length and type body length.
- Is SwiftLint free to use? What license does it have?
- SwiftLint is open source under the MIT license. Check the license terms before using it in commercial products.
- Is SwiftLint still maintained?
- Actively maintained. The last commit to SwiftLint was on Nov 5, 2026.
- What can I use SwiftLint for?
- Enforcing a shared Swift style guide across a team's iOS or macOS projects Running lint checks in CI pipelines through Docker, fastlane, or pre-commit hooks Gradually cleaning up legacy code with baselines and auto-correction
- How do I install SwiftLint?
- Install SwiftLint with Homebrew: brew install swiftlint Run SwiftLint in your project directory: swiftlint
- Where can I get SwiftLint?
- The source code and installation instructions are on GitHub: https://github.com/realm/SwiftLint
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Static code analysis tool for Kotlin projects that flags code smells and style issues, configurable via rule sets and a Gradle plugin.
A static code analyser for Python that checks for errors, enforces coding standards, and flags code smells without running your code.
A strict, opinionated flake8 plugin that enforces consistent, simple Python code style and flags complex code patterns.
A Python linter that checks source files for errors by parsing code without importing it, avoiding style checks.
Self-hosted code quality and security platform that scans projects for bugs, vulnerabilities and maintainability issues, with Quality Gates for CI pipelines.