How to change the compiler in XCode to the one installed by Homebrew

Hi All,

I am using Xcode 15.

I am trying to change the compiler in XCode to use the version of clang++ installed at /opt/homebrew/Cellar/llvm@14/14.0.6/bin/clang-14 However, when I set the compiler under Build Options > Compiler for C/C++/... It gives me an Unsupported Compiler Warning, and from the build messages, it looks like it is defaulting back to Apple's version of Clang.

Is there something I am missing here? Are there additional steps required to get this to work?

Thank you kindly in advance.

Basically the following steps worked for me for this:

  1. Add the LLVM project's toolchain to Xcode's Toolchains:
    1. Make sure the directory ~/Library/Developer/Toolchains exists.
    2. Symbolically link the toolchain /opt/homebrew/Cellar/llvm@14/14.0.6/LLVM14.0.6.xctoolchain within the ~/Library/Developer/Toolchains directory.
  2. Restart or start Xcode.
  3. Go to the Xcode menu dropdown, a "Toolchains" menu option should appear now, select the new toolchain.
  4. Edit your project's OTHER_LDFLAGS setting:
    1. Add -L/opt/homebrew/Cellar/llvm@14/14.0.6/lib/c++
    2. Add -Wl,-rpath,/opt/homebrew/Cellar/llvm@14/14.0.6/lib/c++

Hope this helps.

How to change the compiler in XCode to the one installed by Homebrew
 
 
Q