SwiftLint is a tool to enforce Swift style and conventions.
Using Homebrew:
Simply run the following command in your Terminal:
brew install swiftlint
This will install the SwiftLint binaries and dependencies in your machine.
Using CocoaPods:
Simply add the following line to your Podfile:
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.
This is the recommended way to install a specific version of SwiftLint since it supports installing a pinned version 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 such as
git is discouraged.
After to install, move the file swiftlint.yml
into the same path of your Project.xcodeproj
.
Integrate SwiftLint into your Xcode project to get warnings and errors displayed in the issue navigator.
To do this click the Project in the file navigator, then click the primary app target, and go to Build Phases. Click the + and select "New Run Script Phase".
if which swiftlint >/dev/null; then
swiftlint --config ".swiftlint.yml"
else
echo "warning: SwiftLint not installed, use: brew install swiftlint"
fi
if which swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
After that it needs to look like the screenshot:
Whether you're helping us fix bugs, improve the docs, or spread the word, thank you! 💪 🧡
Check out our Contributing Guide for ideas on contributing and setup steps.
Licensed under the MIT License.