Home > OS >  How can I upgrade the built-in Apple Clang on MacOS?
How can I upgrade the built-in Apple Clang on MacOS?

Time:12-10

My clang on MacOS that is provided by Apple seems to be a bit outdated.

> clang -v
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

But my MacOS is up to date: MacOS Ventura 13.0.1 I have recently installed Xcode version 14.1, but I think the Xcode developer tools (CLI tools) are installed independently.

How can I upgrade the clang that is provided by Apple on MacOS? According to Xcode on Wikipedia it looks like the clang used by Xcode is newer.


Some command outputs:

>where clang
/usr/bin/clang

>xcode-select -p
/Library/Developer/CommandLineTools

>sudo xcode-select -r

xcode-select -p       
/Applications/Xcode.app/Contents/Developer

CodePudding user response:

This looks like you've got remnants of an Xcode 12.5 installation on your system.

Things I would try/check:

  • what does where clang say? Is it /usr/bin/clang?
  • what's the output of xcode-select -p? It should be something like /Applications/Xcode.app/Contents/Developer (depending on where/how you installed Xcode).
  • If the output doesn't look right, try xcode-select -s <path> with the path to your Xcode installation, or try resetting with xcode-select -r
  • running sudo xcode-select --install may force a new installation of the commandline tools

In any case, the output of clang -v on my Ventura box is

Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

as one would expect.

  • Related