Linters
What is SwiftLint? An introduction to Realm's Swift style linter
SwiftLint is a tool that enforces Swift style and conventions. Its rules are loosely based on the archived GitHub Swift Style Guide. It can run as a Swift Package Manager plugin, as an Xcode Run Script Build Phase, or through several other installation routes.
- Tool
- SwiftLint
- Made by
- Realm
- Official site
- github.com/realm/SwiftLint
- Category
- Linters
Who makes SwiftLint
SwiftLint is made by Realm. Its official website is the project's GitHub repository, linked below.
Official website: github.com/realm/SwiftLint
What SwiftLint is for
SwiftLint is for keeping Swift code consistent with agreed style and conventions. It enforces those conventions automatically, so they do not depend on reviewers noticing deviations by hand.
Technically, SwiftLint rules are mostly built on SwiftSyntax, and some also use Clang and SourceKit for type information. SwiftLint is designed to analyze valid, compilable source code, so it is meant to run on code that already builds rather than on code with syntax errors.
Who SwiftLint is for
The vendor does not state a target audience, so this is framing based on the facts. SwiftLint is for developers and teams who write Swift and want a consistent style.
Its integration options cover different project setups. Swift Package projects and Xcode projects are both supported by the build tool plugin, and teams that use Bazel can consume SwiftLint from there.
Notable capabilities
Most of SwiftLint's documented capabilities concern how it is installed and run.
- Build tool plugin: SwiftLint can run as a build tool plugin that works with both Swift Package projects and Xcode projects.
- Command plugin: the command plugin allows running SwiftLint from the command line via Swift Package Manager.
- Config discovery: the build tool plugin finds its working directory by locating the topmost config file in the package or project.
- CocoaPods: SwiftLint can be installed via CocoaPods, which also allows pinning to a specific version.
- Installer package: a downloadable installer package is available from GitHub releases.
- Build from source: SwiftLint can be built from source with make install.
- Bazel: SwiftLint can be consumed from Bazel.
- Xcode Run Script: it can alternatively be added to Xcode as a Run Script Build Phase.
How SwiftLint fits linters
SwiftLint is a style-focused linter for a single language. Its job is enforcing conventions, which is the classic linter role, and it does so for Swift specifically.
For Swift Package Manager users, the dedicated SwiftLintPlugins repository is recommended for consuming the Swift package plugins. In Linthelm's wider niche of linters, static analysis and code quality, SwiftLint covers the style layer for Swift, and it can sit alongside tools that look for bugs or code smells rather than replace them.
Frequently asked questions
What is SwiftLint used for?
SwiftLint is used to enforce Swift style and conventions, loosely based on the archived GitHub Swift Style Guide.
Who makes SwiftLint?
SwiftLint is made by Realm, and its official website is the project's GitHub repository.
How can I install SwiftLint?
SwiftLint can be installed via CocoaPods, through a downloadable installer package from GitHub releases, or built from source with make install. It can also be consumed from Bazel or added to Xcode as a Run Script Build Phase.
Does SwiftLint work with Xcode projects?
Yes. The build tool plugin works with both Swift Package projects and Xcode projects, and SwiftLint can alternatively be added to Xcode as a Run Script Build Phase.
Does SwiftLint analyze code that does not compile?
No. SwiftLint is designed to analyze valid, compilable source code.
Linthelm is independent and is not affiliated with Realm. Product names belong to their owners. Features change; confirm details on the official website.