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

Opaque error message when xcodebuild is unavailable #3565

Open
2 tasks done
macdrevx opened this issue Mar 10, 2021 · 5 comments
Open
2 tasks done

Opaque error message when xcodebuild is unavailable #3565

macdrevx opened this issue Mar 10, 2021 · 5 comments

Comments

@macdrevx
Copy link

New Issue Checklist

Describe the bug

If xcodebuild -version returns

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

swiftlint fails with

$ swiftlint lint
Fatal error: Loading sourcekitd.framework/Versions/A/sourcekitd failed: file SourceKittenFramework/library_wrapper.swift, line 31
[1]    83461 trace trap  swiftlint lint

Could we add some kind of detection for this condition and emit a more useful error message?

Complete output when running SwiftLint, including the stack trace and command used

Crash report:
swiftlint_2021-03-10-100023_H2WF637UQ6NY.crash.zip

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.43.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
  • Paste your configuration file:

See https://github.com/mapbox/mapbox-maps-ios/tree/412981f0712d5f76d6ce41015d21e9fdb9cdb521

Yes:

$ find . -name ".swiftlint.yml" 
./.swiftlint.yml
./Tests/.swiftlint.yml
./Sources/.swiftlint.yml
  • Which Xcode version are you using (check xcodebuild -version)?
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
  • 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.

No

@jpsim
Copy link
Collaborator

jpsim commented Mar 10, 2021

I agree this error isn't great. It's coming from here by the way: https://github.com/jpsim/SourceKitten/blob/863680921bcc3ba9785c9584d4dd195f8597c7d8/Source/SourceKittenFramework/library_wrapper.swift#L31

We'd need to change that from a fatal error to a non-fatal error that can be caught and handled.

Or perform validation up front before trying to load libraries that may not be available.

@htmlprogrammist
Copy link

Same problem here. Installation using homebrew

@gpoitch
Copy link

gpoitch commented Jul 16, 2023

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer then it works

@micHar
Copy link

micHar commented Sep 6, 2023

Keep in mind that there are also other options to fix the xcode-select issue, be sure to check them out before running sudo xcode-select -switch.... https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error

@duyhungtnn
Copy link

I was facing this recently , here is solution #1466 (comment)

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

No branches or pull requests

6 participants