Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not get cursor info - Analyze error (with Xcode 12) #3365

Closed
2 tasks done
AleMaMi opened this issue Sep 23, 2020 · 6 comments · Fixed by #3366
Closed
2 tasks done

Could not get cursor info - Analyze error (with Xcode 12) #3365

AleMaMi opened this issue Sep 23, 2020 · 6 comments · Fixed by #3366

Comments

@AleMaMi
Copy link

AleMaMi commented Sep 23, 2020

New Issue Checklist

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.log
Complete 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 version to 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 use swiftlint lint --path [file here] --no-cache --enable-all-rules.
@AleMaMi
Copy link
Author

AleMaMi commented Sep 23, 2020

Adding example
SwiftlintExample.zip

@jpsim
Copy link
Collaborator

jpsim commented Sep 23, 2020

Thanks for reporting this so quickly after release. I’ll look into what might not be working for your project.

@AleMaMi
Copy link
Author

AleMaMi commented Sep 23, 2020

Thanks for reporting this so quickly after release. I’ll look into what might not be working for your project.

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
Copy link
Collaborator

jpsim commented 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. @main attribute, or structs conforming to PreviewProvider). I should have a fix for all these up shortly.

@jpsim
Copy link
Collaborator

jpsim commented 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
Copy link
Author

AleMaMi commented Sep 25, 2020

Hi. I can confirm it works now fine. No errors / warnings and analyze detects my rules properly. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants