realm /SwiftLint
A tool to enforce Swift style and conventions.
★ 19,791⑂ 2,345👁 230⑃ 4,059● 2,871▤ 153
More from this author
+0
Daily
19,791
stars
2,345
forks
230
watchers
4,059
prs
2,871
issues
153
releases
README
SwiftLint
A tool to enforce Swift style and conventions, loosely based on the now
archived GitHub Swift Style Guide.
SwiftLint enforces the style guide rules that are generally accepted by the
Swift community. These rules are well described in popular style guides like
Kodeco's Swift Style Guide.
SwiftLint rules are predominantly based on SwiftSyntax.
Some rules still hook into Clang and
SourceKit to access type information.
!SwiftLint violations highlighted in the Xcode editor
This project adheres to the
Contributor Covenant Code of Conduct.
By participating, you are expected to uphold this code.
Switch Language:
中文,
한국어
Video Introduction
To get a high-level overview of SwiftLint, we encourage you to watch this
presentation recorded January 9th, 2017 by JP Simard (transcript provided):
Installation
Swift Package Manager
SwiftLint can be used as a command plugin
or a build tool plugin.
Add
swift
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", from: "")
to your Package.swift file to consume the latest release of SwiftLint
automatically or pin the dependency to a specific version:
swift
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", exact: "")
Therein, replace with the desired minimum or exact version.
[!NOTE]
Consuming the plugins directly from the SwiftLint repository comes
with several drawbacks. To avoid them and reduce the overhead imposed, it's
highly recommended to consume the plugins from the dedicated
SwiftLintPlugins repository,
even though plugins from the SwiftLint repository are also absolutely
functional. If the plugins from SwiftLint are preferred, just use the URL
https://github.com/realm/SwiftLint in the package declarations above.
However, SwiftLintPlugins
facilitates plugin adoption massively. It lists some of the reasons that
drive the plugins as provided by SwiftLint itself very troublesome. Since
the plugin code and the releases are kept in sync, there is no difference
in functionality between the two, but you spare yourself a lot of time and
trouble using the dedicated plugins repository.
This document assumes you're relying on SwiftLintPlugins.
Xcode Package Dependency
Use the following link to add SwiftLint as a Package Dependency to an Xcode
project:
bash
https://github.com/SimplyDanny/SwiftLintPlugins
Homebrew
bash
brew install swiftlint
CocoaPods
Add the following to your Podfile:
ruby
pod 'SwiftLint'
This will download the SwiftLint binaries and dependencies in Pods/ during
your next pod install execution and will allow you to invoke it via
${PODS_ROOT}/SwiftLint/swiftlint in your Script Build Phases.
Installing via Cocoapods also enables pinning to a specific version of
SwiftLint rather than simply the latest (which is the case with
Homebrew).
Note that this will add the SwiftLint binaries, its dependencies' binaries, and
the Swift binary library distribution to the Pods/ directory, so checking in
this directory to SCM Top issues
#4015Xcode 14 introduces new run script build phase warning for SwiftLint44 comments · 2022-07-05#319Add Rules to Support Ray Wenderlich's Swift Style Guide32 comments · 2016-01-06#27Support Xcode Fix-Its26 comments · 2015-05-22#3988Bus error18 comments · 2022-06-03#3046indentation_width warning on multiple cases of switch-case18 comments · 2020-01-17#5207Running lint without any code changes is still slow (30s vs 40s without cache)16 comments · 2023-09-07#1573Support tabs in vertical parameter alignment rule16 comments · 2017-05-26#4821Fatal error while scanning apple/swift repo15 comments · 2023-03-15
Latest release
0.65.1: Fresh Folded Fixtures 0.65.1 2026-08-21Breaking Configuration.IndentationStyle moved to SwiftLintCore.IndentationStyle. Rules can now read the global indentation setting via CurrentRule.configuration. GandaLF2006 Remove the deprecated allow_multiline_func option from the opening_brace rule. Use ignore_multiline_function_signatures instead. Brett-Best Enhancements Speed up the collection_alignment rule, which read the whole file's source lines once per element of a dictionary literal. Brett-Best Compare the two operands of a comparison by walking their token streams in the identical_ope