iOS Dev Nugget 188 SwiftLint


Need to run a code review on your codebase? Hire me

One of the most important parts of writing code is writing maintainable code. In a group setting especially, a style guide is very important. Lint tools help to enforce that (as well as checking for certain types of bugs). SwiftLint is a lint tool that is based on GitHub's Swift Style Guide.

Install it with Homebrew:

brew install swiftlint

There are 2 ways to use it, either A) run it from the shell, which will examine Swift code files in the current directory:


Or B) Add a Run Script Phase:

if which swiftlint >/dev/null; then
    echo "warning: SwiftLint not installed, download from"

As with all things Swift, it's a relatively new tool and it implements 31 rules as of writing.

There are more options such as using the autocorrect option and more, described in the README.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No



Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter


View archives of past issues