# SwiftLint

> A tool to enforce Swift style and conventions

- Type: agent or tool
- Field: Code Review & Testing
- Repository: https://github.com/realm/SwiftLint
- GitHub stars: 19795
- Licence: MIT
- Language: Swift
- Last push: 2026-11-24
- Page: https://imutechz.in/agents/swiftlint

## What it is
SwiftLint is a tool that enforces Swift style and conventions, loosely based on the archived GitHub Swift Style Guide. It enforces rules generally accepted by the Swift community, as described in popular style guides like Kodeco's. Its rules are predominantly based on SwiftSyntax, with some rules hooking into Clang and SourceKit to access type information. It is aimed at Swift developers who want to keep their code consistent.

## Features
- Enforces Swift style and convention rules
- Rules predominantly based on SwiftSyntax
- Some rules use Clang and SourceKit for type information
- Can be used as a Swift Package command plugin or build tool plugin
- Installable via Homebrew, CocoaPods, Mint and Bazel
- Highlights violations in the Xcode editor

## Best for
- Enforcing a consistent Swift code style
- Catching style violations in Xcode
- Adding linting to Swift Package builds
- Pinning a specific SwiftLint version via CocoaPods

## Pros
- Enforces rules generally accepted by the Swift community
- Rules are well described in popular style guides
- Can be consumed as a Swift Package plugin or build tool plugin
- CocoaPods install allows pinning to a specific version

## Cons
- Consuming plugins directly from the SwiftLint repository has drawbacks; the dedicated SwiftLintPlugins repository is recommended
- CocoaPods install adds SwiftLint binaries, dependency binaries and the Swift binary library to Pods/, so checking that directory into Git is discouraged
- Homebrew installs the latest version rather than a pinned one

## Install
```
brew install swiftlint
```

Tags: swift, lint, style-guide, code-style, static-analysis, xcode, swift-package-manager, cocoapods
