SwiftLint
We are introducing mandatory linting for iOS. A linter is a tool to enforce Swift style and conventions.
Last updated
We are introducing mandatory linting for iOS. A linter is a tool to enforce Swift style and conventions.
Last updated
Linting is important and we want to adapt a uniform linter across all iOS projects.
To use swiftlint, we just have to install it with brew. In terminal, run:
Integrate SwiftLint into an Xcode scheme to get warnings and errors displayed in the IDE. Just add a new "Run Script Phase" with:
This file will control the rules and how the the swiftlint framework will operate. In the root directory of the project, create a new file called .swiftlint.yml
A swiftlint.yml defines all the rules we want to use/ignore when linting. Here is a good starting file, but feel free to modify it as needed. Make sure you replace YOUR_PROJECT_FOLDER with your project folder name.
You can read more about swiftlint rules here.
One of the cool features swiftlint is autocorrect. SwiftLint can automagically fix simple issues with your code. To run this, just go into the root directory on termial and run swiftlint autocorrect