Update 2013-11-13 Added paths for Xcode 4.2 and 3.6
I do a lot of my coding on osx, and was getting annoyed that I could not pick a specific compiler from within Xcode that I had installed. Using makefiles is an option but I wanted to see if I could add a new compiler to Xcode 4. This guide was the basis for mine, tweaked for Xcode 4
Xcode 4 and gcc-4.7 will be used as the example, in theory any compiler can be used (I have not tested this). This requires that you have installed gcc-4.7 from macports (usually gcc-mp-4.7)
Open up a terminal window (Root privileges will be required for some steps!) Go to you applications folder and open up the “Xcode.app” package.
For Xcode 4.2 the correct path is (thanks to Joram Vanhaerens for this info) stack overflow
For Xcode 3.6 the correct path is (untested)
Next create a copy of GCC 4.2.xcplugin and put it in the Xcode plugin path make the /Library/Application Support/Developer/Shared/Xcode/Plug-ins/ if it doesn’t already exist
Navigate into package
Next we need to convert the plist into xml as it is in binary so that we can edit it (if you’d prefer to use something other than vi, feel free)
Make the following changes:
Convert Info.plist back to binary
In the “Resources” folder rename “GCC 4.2.xcspec” to “GCC 4.7.xcspec” In the “Englist.lproj” folder rename “GCC 4.2.strings” to “GCC 4.7.strings”
Open the GCC 4.7.xcspec file and change, make sure to use sudo:
Now, at this point the compiler should appear in Xcode (make sure to exit and open up Xcode again) but will probably error out due to some compiler flags which we need to fix
open up GCC 4.7.xcspec
in your Xcode project under “Other Warning Flags” remove the -Wmost option
Compilation should now work!
Feel free to shoot me an email at email@example.com if you have suggestions on how to improve this guide.