开发者

Use LLVM compiler by default for all Xcode projects?

开发者 https://www.devze.com 2023-02-06 11:59 出处:网络
I really enjoy switching from gcc to LLVM compiler, but do I have to switch manually every time I start a new project, or is there any way to make LLVM the default compiler?

I really enjoy switching from gcc to LLVM compiler, but do I have to switch manually every time I start a new project, or is there any way to make LLVM the default compiler?

I'm talking about xcode 3.

Thank开发者_StackOverflows.


To accomplish this you will have to modify the project template within the Developer directory.

Navigate to where your templates are (probably something like: /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/

Once you're there, you can select the project template you wish to modify, and locate it's .xcodeproj file. You can "show package contents" and inside is a project.pbxproj. You can modify this file and edit in the build setting to change the default compiler.

You'll have to find each section that relates to the build settings for each configuration (Debug, Release etc.), search for /* Begin XCBuildConfiguration section */.

Then you'll have to add GCC_VERSION as a key and com.apple.compilers.llvm.clang.1_0 as the value (1_0 in this instance is actually LLVM 1.6 according to Xcode. I also assume that the key-name GCC_VERSION only has GCC in it for legacy reasons, this will probably be updated to COMPILER_VERSION or something in the future).

Save the template and create a new project (You may have to restart Xcode if it was open). The compiler should be set to LLVM now.

However, I don't recommend you do this as LLVM still isn't 100% fit for deploying applications to users.


I don't believe there's an (easy) way to do this. (i.e.: There's no preference pane option for such a thing.) That said, the advice within the existing Setting GCC 4.2 as the default compiler on Mac OS X Leopard question should work @Jasariens answer seems ideal, if the per-project setting is proving tiresome.

However, LLVM isn't quite ready for prime time, so I'd really recommend not using it for the final deployment of apps, etc. (If you're encountering any odd issues, switch back to using GCC and they'll quite possibly go away.)

Incidentally, whilst off-topic, there's some great tips within the Hidden Features of Xcode question as well, so that might be worthy of a browse. :-)


The very easiest way (and smartest, I think) to do it for all future projects is to do the following 5 steps :

  1. go to /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iPhone Base.xctemplate (you can simply Command + o (open) in Xcode then Command + Shift + G (go to folder), then paste this path)
  2. open the file TemplateInfo.plist in Xcode
  3. go to Project > SharedSettings > GCC_VERSION property and change its String value to com.apple.compilers.llvm.clang.1_0 : http://grab.by/a0dV
  4. save the file
  5. test by opening a new iPhone project.

You can do the same for other new project by going to, for example, /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iPad Base.xctemplate for the iPad projects, etc.

That's it.

Have a nice day everybody.


I’ve written a simple script that creates a fresh Xcode project with sane defaults. Might be worth adapting, so that you don’t have to set up every new project by hand.


All answers tell how to change default compiler value for new projects.

This is how to change directly the "iOS default" values in XCode for any projects :

EDIT the file (with sudo)

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSXXXX.sdk/SDKSettings.plist

Restart XCode and done!

0

精彩评论

暂无评论...
验证码 换一张
取 消