简体   繁体   中英

How can I find all Clang versions installed on my Mac?

clang --version
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

which clang
/usr/bin/clang

I'm on Mac, 10.13.6, any instructions would be appreciated!

You can use which -a clang to list all of the clang s on your PATH . Ones which aren't on your PATH , like if you've installed Clang somewhere out of the ordinary, won't be shown.

A complication is that /usr/bin/clang is actually a trampoline that launches the clang within the currently active developer dir, selected by xcode-select or the DEVELOPER_DIR environment variable. So, knowing that /usr/bin/clang is there doesn't tell you either which one it will bounce to or which other versions could be activated. xcrun -f clang will tell the first (which will be bounced to). To my knowledge, there's no way to get Apple's tools to list out the possible developer dirs. So, if you have multiple versions of Xcode (or the Command Line Tools) installed, which -a clang won't see them.

A more reliable way would be to search the file system. You could use find / -type f -perm +a+x -name clang , but that will be slow. The other thing you can try is Spotlight, but I find that the internals of Xcode app bundles are not indexed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM