Skip to content

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

Closed

Description

@AleMaMi

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.

Activity

  1. AleMaMi commented on Sep 23, 2020

    @AleMaMi
    Author

    Adding example
    SwiftlintExample.zip

  2. jpsim commented on Sep 23, 2020

    @jpsim
    Collaborator

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

  3. AleMaMi commented on Sep 23, 2020

    @AleMaMi
    Author

    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.

  4. jpsim commented on Sep 23, 2020

    @jpsim
    Collaborator

    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.

  5. jpsim commented on Sep 23, 2020

    @jpsim
    Collaborator

    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!

  6. AleMaMi commented on Sep 25, 2020

    @AleMaMi
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions