4

I installed the recent version of clang (to /usr/local/). How do I set up Xcode to use this and not the built-in version of clang?

  • This should be on StackOverflow as is about development tools – Mark Jun 18 '13 at 23:54
  • @Mark as for your own question in Meta, the question shouldn't be considered off-topic. – Thecafremo Jun 19 '13 at 7:24
  • @Thecafremo - This is not about how to use the windows in Xcode which could be considered OSX use but about how to program with Xcode (also I think this has been answered in SO before) – Mark Jun 19 '13 at 9:16
  • @Mark He is asking for a way of configuring Xcode, not a way of developing with it. – Thecafremo Jun 19 '13 at 14:05
2

This is a copy of my answer on StackOverflow: How can I force Xcode to use custom compiler?.

People say it is possible with custom toolchains. I didn't make a research on them because easier solution worked well for me:

It is also possible to run frontend plugins directly by setting appropriate "build settings" of Xcode. (Several ways to do this, you can set them on the command line for instance: xcodebuild build FOO=bla.) Here are a few build settings that I found useful to inject C flags:

OTHER_CFLAGS, OTHER_CPLUSPLUSFLAGS or to replace the compiler(s) and linker(s):

CC, CPLUSPLUS, LD, LDPLUSPLUS, LIBTOOL

The same approach works to control the "analyze" action: CLANG_ANALYZER_EXEC, CLANG_ANALYZER_OTHER_FLAGS

Disclaimer: some of those build settings are undocumented (afaik). Use at your own risk.

(Taken from [cfe-dev] Compile/refactor iOS Xcode projects)

For me it was enough to define the following User-Defined Settings in Build Settings of Xcode projects:

CC=my-c-compiler

CXX=my-cxx-compiler

LIBTOOL=my-linker-for-static-libraries

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .