Repository navigation
Closed
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Describe the bug
Running swiftlint analyze does not detect issues, but shows error Could not get cursor info. It can be reproduced with very simple freshly generated Xcode project (I have created SwiftlintExample project and added AnalyzeClass.swift with unused import and unused class to trigger detection).
$ xcodebuild -project SwiftlintExample.xcodeproj -scheme SwiftlintExample > xcodebuild.logComplete output when running SwiftLint, including the stack trace and command used
$ ❯ swiftlint analyze --compiler-log-path xcodebuild.log
Loading configuration from '.swiftlint.yml'
Analyzing Swift files at paths
Collecting 'SwiftlintExampleApp.swift' (1/3)
Collecting 'ContentView.swift' (2/3)
Collecting 'AnalyzeClass.swift' (3/3)
Could not index file at path '<path>/SwiftlintExample/SwiftlintExample/AnalyzeClass.swift' with the unused_declaration rule.
Could not index file at path '<path>/SwiftlintExample/SwiftlintExample/SwiftlintExampleApp.swift' with the unused_declaration rule.
Could not index file at path '<path>/SwiftlintExample/SwiftlintExample/ContentView.swift' with the unused_declaration rule.
Analyzing 'SwiftlintExampleApp.swift' (1/3)
Analyzing 'AnalyzeClass.swift' (2/3)
Analyzing 'ContentView.swift' (3/3)
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Could not get cursor info
Done analyzing! Found 0 violations, 0 serious in 3 files.Environment
- SwiftLint version (run
swiftlint versionto be sure)? 0.40.3 - Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
- Paste your configuration file:
included:
- SwiftlintExample
analyzer_rules:
- unused_declaration
- unused_import- Are you using nested configurations? NO
If so, paste their relative paths and respective contents. - Which Xcode version are you using (check
xcodebuild -version)? Xcode 12.0 / Build version 12A7209 - Do you have a sample that shows the issue? Run
echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
to quickly test if your example is really demonstrating the issue. If your example is more
complex, you can useswiftlint lint --path [file here] --no-cache --enable-all-rules.
Metadata
Metadata
Assignees
Labels
No labels
Activity
AleMaMi commentedon Sep 23, 2020
Adding example
SwiftlintExample.zip
jpsim commentedon Sep 23, 2020
Thanks for reporting this so quickly after release. I’ll look into what might not be working for your project.
AleMaMi commentedon Sep 23, 2020
I have tried older Swiftlint version (0.39.2) and result is the same. I worry the reason is Xcode 12, I am pretty sure analyze was working fine before Xcode update.
jpsim commentedon Sep 23, 2020
Yes, I'm digging into this. It's an Xcode 12 issue, but the project you shared has also highlighted that we're incorrectly marking some SwiftUI declarations as unused, but they're used by the tooling or runtime (e.g.
@mainattribute, or structs conforming toPreviewProvider). I should have a fix for all these up shortly.jpsim commentedon Sep 23, 2020
When you get a chance could you please try the master branch on your projects to see if everything works as you'd expect?
Thanks!
AleMaMi commentedon Sep 25, 2020
Hi. I can confirm it works now fine. No errors / warnings and
analyzedetects my rules properly. Thanks a lot!