I'd like to use swiftlint to lint a single file. How do I accomplish this? Checking the docs on https://github.com/realm/SwiftLint was not helpful.
Running SwiftLint on Build The best way to execute a linting tool is to have it run every time you build the Xcode Project. It means that the SwiftLint rules will be applied every time you compile your code.
You can integrate SwiftLint as a Xcode Build Tool Plug-in if you're working with a project in Xcode. Add SwiftLint as a package dependency to your project without linking any of the products. Select the target you want to add linting to and open the Build Phases inspector.
If you wish to autocorrect violations as well, your script could run swiftlint autocorrect && swiftlint instead of just swiftlint . This will mean that all correctable violations are fixed, while ensuring warnings show up in your project for remaining violations.
swiftlint. yml file to your project directory. Note that this file should be added alongside your Xcode project and your Xcode workspace. It should not be placed inside of your project files directory.
You can also do this with:
swiftlint --path 'path to your file'
SCRIPT_INPUT_FILE_COUNT=1 SCRIPT_INPUT_FILE_0="foo.swift" swiftlint lint --use-script-input-files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With