SwiftLint is an open-source tool used to enforce styles and conventions.
Installing it is not difficult, but someone might need a few hints, so I have prepared this blog post to explain them.
First of all, you need to download it from GitHub, download the latest SwiftLink.pkg from the GitHub release page.
You won't be able to open it, because you will get this popup message:
After the message, you need to go to System Preferences >>> Security & Privacy, and click "Open Anyway":
Finally, add SwiftLint to your project in a new Run Script Phase:
- select your project;
- select your target;
- select the Build Phases tab;
- click on the + icon;
- select New Run Script Phase;
- copy and paste the below script:
if which swiftlint >/dev/null; then swiftlint else echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" fi
You can find more advance info in this blog post: How to use SwiftLint with Xcode to enforce Swift style and conventions?