0

I am using swiftlint for my project with SPM

I want to use unused_imports rule like this:

...
analyzer_rules:
  - unused_import
...

But it does not find any violations, even thought they are in the project

I have also tried turn it on in the opt-in-rules section

Do you have any ideas, why this could happened?

I am running swiftlint lint --autocorrect

Daniel Pustotin
  • 237
  • 1
  • 9
  • This isn’t something swiftlint can handle in normal mode, you need to run `swiftlint analyze`, please read the documentation for more detailed information – Joakim Danielson Sep 11 '22 at 18:53

1 Answers1

3

I found the solution

You need to build your project (or workspace) using xcodebuild tool and save the build logs

Then you may use it to run swiftLint analyze

I created this makefile script to do so:

# Run swiftlint analyze
lint-analyze:
make clean
    xcodebuild \
    -project <YOUR_PROJECT>.xcodeproj \
    -scheme <YOUR_SCHEME> \
    -destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.5' \
    > xcodebuild.log 
    swiftlint analyze --fix --compiler-log-path xcodebuild.log --quiet
    swiftlint lint --fix --format --quiet
maxmitz
  • 258
  • 1
  • 4
  • 17
Daniel Pustotin
  • 237
  • 1
  • 9