- Apple LLVM编译器3.0
- GCC LLVM 4.2
[ 15:30 jon@MacBookPro / ]$
开头的行时,需要打开Terminal.app并运行以$
开始的命令。
在此过程中不会删除任何文件或目录,因此如果将来需要使用LLVM进行编译,则可以轻松撤销。
Download - but do not install yet - xcode_4.1_for_lion.dmg or xcode_4.1_for_snow_leopard.dmg
Now, follow these steps to install Xcode 4.1 into /Developer-4.1
:
Backup the working /Developer
directory (where Xcode 4.2 is installed)
[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2
Run the Xcode 4.1 installer using the default install location (/Developer
)
Move the new Xcode 4.1 installation to /Developer-4.1
:
[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1
Move the Xcode 4.2 developer directory back to /Developer
:
[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer-4.2 /Developer
Edit the Xcode 4.2 GCC 4.2.xcspec
file to get gcc 4.2 to show in the list of compiler options [1]:
[ 15:30 jon@MacBookPro / ]$ sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2 (Plausible Blocks).xcplugin/Contents/Resources/GCC 4.2.xcspec"
Change lines 41 and 42 from this:
ShowInCompilerSelectionPopup = NO;
IsNoLongerSupported = YES;
To This:
ShowInCompilerSelectionPopup = YES;
IsNoLongerSupported = NO;
Backup the Xcode 4.2 iOS/Simulator Framework usr
directories:
[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr.backup
[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneSimulator.platform/Developer/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr.backup
Copy Xcode 4.1 iOS/Simulator Framework usr
directories to Xcode 4.2:
[ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr
[ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr
Copy the gcc
and info
iOS SDK library directories from Xcode 4.1 to Xcode 4.2 [2]:
[ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/gcc /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc
[ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/info /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/info
使用gcc-4.2进行编译!
这是我撰写的一篇博客文章,更详细地介绍了这个过程。如果遇到任何问题或有任何疑问,请随时在博客上留言。
[1] 如果从命令行打开(使用类似vi
、emacs
、nano
等),请确保将路径用引号括起来"/long path/with spaces/in it/file.xcspec",或转义空格/some/long\ path/with\ spaces/in\ it/file.xcspec
[2] 这是必要的,因为iPhoneOS.platform SDK有自己单独的/usr/lib
目录,而iPhoneSimulator.platform SDK没有
Xcode 4.3有一个特定的文件夹/Applications/Xcode.app/Contents/Developer/Toolchains
。
是否有办法添加其他的工具链,比如AVR-gcc和PIC32-gcc?