如何让Xcode使用替代版本的?? [英] How do I make Xcode use an alternative version of clang?

查看:713
本文介绍了如何让Xcode使用替代版本的??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置Xcode以使用通过(这或多或少是你采取的方法)。通过只更改Clang版本,在编译之后,您可能会在输入时得到不同于编辑器中显示的警告。


How can I set up Xcode up to use the clang distributed by llvm.org instead of the one shipped by Apple?

If I download the clang binaries and install to /usr/local and then set my compiler to Other... -> /usr/local/bin/clang in Xcode, then I get errors of the form:

Unsupported compiler '/usr/local/bin/clang' selected for architecture 'x86_64'

Unable to determine concrete GCC compiler for file ...of type sourcecode.c.c.

UPDATE: I've found a way to make this work by symlinking /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr to the clang+llvm-3.4-x86_64-apple-darwin10.9 root directory, but it would be far better it there was a way to set an alternative compiler for Xcode without modifying the Xcode directory tree.

解决方案

The easiest option (also the easiest to reverse) is to add the CC build flag. Go to your project's or target's build settings, and choose Editor --> Add Build Setting --> Add User-Defined Setting from the menu.

Name the flag CC, and set the value to the path to your Clang binary.

You can choose whether you want to use this compiler for all builds, or just debug builds (this makes sense when you use experimental and/or self-modified versions of Clang, for instance).

Note that for features like autocompletion, symbolic search etc., Xcode does not use the Clang binary but other LLVM libraries distributed with Xcode. I've described how to replace those in another post (which is more or less the same approach that you took). By only changing the Clang version, you may get different warnings after compiling than those shown in the editor while typing.

这篇关于如何让Xcode使用替代版本的??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆