Notes on swift lint
Swift-lint
-
install swift-lint via swiftlint.pkg (give access in prefs/security): https://github.com/realm/SwiftLint/releases
- Add
.swiftlint.yml
to your xcode project folder- Example of swift-lint rule set: https://github.com/realm/SwiftLint/blob/master/.swiftlint.yml
- Another swift-lint example from Sindre Sorhus project GifSki: https://github.com/sindresorhus/gifski-app/blob/master/.swiftlint.yml
- Add swift-lint script to your xcodeproject:
- XCode 👉 Build phases
- Click “plus-button” 👉 Add run script
- Paste in the bellow:
if which swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
-
Build the project to see some swift-lint warnings
-
Add a swift-lint badge to your github project:
[](https://github.com/eonist/Swift-lint)
-
✨ Don’t forget the terminal auto correct feature Terminal:
swiftlint autocorrect
in your project path. And it auto corrects the entire project ✨ ⚠️️Remember to commit before you auto correct the project.
Notes:
you can disable swift lint inline (copy the arg name like: empty_enum_arguments fro the warning):
// swiftlint:disable empty_enum_arguments
(100, 30, 3),
(10000, 30, 333),
(1000000, 30, 33333),
(100000000, 60, 1666666),
(10000000000, 90, 111111111),
// swiftlint:enable empty_enum_arguments
// swiftlint:disable empty_enum_arguments
// swiftlint:enable empty_enum_arguments
// swiftlint:disable all // swiftlint:enable all
Exclude folders from linting:
excluded:
- Pods
- UnitTests/generated/GeneratedMocks.swift