Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4 Apps
Unfortunately Apple decided to drop support for PPC, SDKs 10.4/10.5 and GCC 4.0 in Xcode4. This hasn't been done for technical reasons, though, but only because Apple wanted to do that. If you have a parallel installation of Xcode3 on your Mac, you can easily restore all that functionality to Xcode4. I posted a detailed step by step guide at Stack Overflow how this can be done. For convenience and to reach a wider audience I'm posting it here again.

Before I get to the how it is done part, here are some notes about my patch/hack/fix. Right from the start the major goals have been:
  • Keep all modifications to an absolute minimum.
    We want to keep the Xcode setups as original as possible.
  • By all means, try to avoid patching or modifying any files.
    We want all files to stay untouched and keep their original content.
  • Try to avoid moving or copying files around, unless absolutely necessary.
I was able to keep all those goals. Almost everything is done by creating symlinks. Only a single existing symlink had to be replaced and we'll back it up before replacement, just in case.

If you are no expert on terminal operations, I strongly advise you to copy/paste all terminal commands from my reply to your terminal, to avoid typos. Bear in mind that even spacing, quoting and especially capitalization can be important. Copy/paste them line by line, never more than one line at once and hit return after each pasted line to execute the command. Should any operation ever prompt you for a password, this will be the password of the currently logged in administrator user (your keystrokes are not displayed while typing, this is normal, don't worry, just keep typing the password and hit return; re-try if you had a typo and get prompted again).

Prerequisites

Before we can start, make sure the following conditions are true:
  • You are logged in as an administrator user.
  • You have started Terminal.app (Applications/Utilities) and a terminal window is open.
  • You have a copy of the Xcode3 (e.g. 3.2.5) and Xcode4 disk image (DMG) or installer available.
  • If you already have either Xcode version installed, consider uninstalling it first, so you can start with a fresh/clean setup. Uninstalling Xcode will not remove your preferences, color scheme or key binding customizations. Ideally you'd start with a system that has no Xcode version (neither 3 nor 4) currently installed.
Step 1: Installing Xcode3

Important: Do not install either the System Tools or Unix Development packages of Xcode3.
Whether you want to install Mac OS X 10.4 SDK and/or Documentation is up to you. If that is a Xcode3 with iOS SDKs, whether you install those or not is also up to you.

You are free to choose any destination folder for your installation. For this guide I have chosen /Xcode3, but feel free to pick a different one. Just make sure to alter all terminal commands accordingly.

The order of the steps given here is usually not really important, but I strongly advise you to not swap step 1 and step 2. Xcode always installs a couple of files outside of the chosen destination folder and trust me, in the end you want the Xcode4 versions of those files on your disk. By installing Xcode3 before Xcode4, you can be sure that Xcode4 will overwrite those files if necessary. I once swapped steps 1 and 2 and in the end I had some rather strange issues that might have been related to the incorrect order (I cannot say for sure, but after re-installing in the correct order the issues were gone).

Step 2: Installing Xcode4

Chose any packets you like. Installing System Tools is advisable, but not strictly necessary (though most people will sooner or later miss that functionality).

Again, feel free to pick any target folder you like. For this guide I chose the normal target folder /Developer; if you take a different one, alter all terminal commands accordingly.

Step 3: Restoring 10.4/10.5 SDK Support

Switch to your terminal window and run the following commands:
cd /Developer/SDKs
sudo ln -s /Xcode3/SDKs/MacOSX10.4u.sdk .
sudo ln -s /Xcode3/SDKs/MacOSX10.5.sdk . 
Of course only run the command for 10.4u if you also installed SDK 10.4 in step 1.

This is enough to bring the SDKs 10.5 (and possibly 10.4) back to the selection list in Xcode4. Give it a try if you like. Fire up Xcode4, open a project, try changing the selected SDK. That was easy, huh? Be sure to close Xcode4 again (the application, not just the window) before proceeding with the next step.

Step 4: Restoring GCC 4.0 Support

If you have not installed MacOS 10.4 SDK or if you don't plan to ever use it, you can safely skip this step and proceed with step 5.

To use SDK 10.4, you'll have to use GCC 4.0, GCC 4.2 won't work. Apple claims that GCC 4.2 is not compatible with SDK 10.4, well, if you ask me, this is a hoax. I have already overwritten this limitations more than once and there was never the tiniest issue because of it. It would be easy to modify SDK 10.4 so that Xcode will allow you to use GCC 4.2 for it, but my goal was to avoid all file modifications, so we just add GCC 4.0 support back to Xcode, which is also a good thing, because some projects really depend on GCC 4.0 (e.g. there are some bugs in GCC 4.2 that prevent valid inline assembly code to compile without errors, while the same code compiles flawlessly on GCC 4.0 and GCC 4.4).

Back to terminal:
cd /Developer/usr/bin
for SRC_FILE in /Xcode3/usr/bin/*4.0*; do sudo ln -s "$SRC_FILE" .; done

cd /Developer/usr/libexec/gcc/powerpc-apple-darwin10
sudo ln -s /Xcode3/usr/libexec/gcc/powerpc-apple-darwin10/4.0.1 .
Right now we have restored full GCC 4.0 support except for the fact that GCC 4.0 is still not selectable in Xcode4. That is because Xcode4 has no GCC 4.0 compiler plug-in any longer. Fortunately the Xcode3 plug-in also works in Xcode4, only the position has radically changed. Apple now hides those plug-ins deep within a bundle and only plug-ins there seem to work, placing them to their old position seems to have no effect.
cd /Developer/Library/Xcode/PrivatePlugIns
cd Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins
sudo ln -s "/Xcode3/Library/Xcode/Plug-ins/GCC 4.0.xcplugin" . 
Now fire up Xcode4 again, open a project and try selecting the compiler. You should have GCC 4.0 back on the list. Now you can actually already select SDK 10.4 or 10.5, GCC 4.0 and you should have no issue to build a PPC binary. Just select 'Other...' for the 'Architecture' build setting and manually enter 'ppc', then alter 'Valid Architectures' to also include 'ppc'. We are almost done, except that trying to build a PPC binary using GCC 4.2 and SDK 10.5 will still fail.

Step 5: Restoring PPC Support for GCC 4.2

Since Apple is only supporting Intel platforms in Xcode4, their fat binaries only have i386 and x86_64 code, but no ppc or ppc64 code. For most binaries this is no issue, as you can only run Xcode4 on an Intel platform in the first place, ppc/ppc64 fat binaries are not necessary, even if the resulting binary is compiled/linked for those platforms. However, there is one tool where this is important. The tool is named 'as' and it is the GNU Assembler. To compile ppc/ppc64 binaries with GCC 4.2 we need a fat binary 'as' version with ppc/ppc64 code. This is the one and only file (actually it also a symlink) we have to first move aside (making a backup copy) before we can replace it by a symlink:
cd /Developer/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1
sudo mv as as.bak
sudo ln -s /Xcode3/usr/bin/as .
Step 6: There is No Step 6

That's all folks. Considering how easy that was, you can imagine that Apple has certainly not dropped SDK 10.4/10.5 or ppc/ppc64 or GCC 4.0 support because this was a necessity, they dropped all that because they wanted to drop it.

I hope this setup works as well for you as it does for me. I have been able to compile all my old projects in Xcode4 without any major changes, except for having to alter a search path here and there.

[crarko adds: I haven't tested this one. But considering that Xcode4 is final now it's likely support for Xcode3 will fade pretty quickly. It's very handy to have the ability to both update the environment but still be able to build the earlier projects. I currently have machines with Xcode3 and one with Xcode4, and would like to update the others. Here's the link to the original article, and there is other related information available there as well.]
    •    
  • Currently 4.60 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (10 votes cast)
 
[23,349 views]  

Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4 | 13 comments | Create New Account
Click here to return to the 'Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
Authored by: Geobunny on Mar 18, '11 08:20:25AM

Brilliant! I haven't followed the instructions yet, but will do so as soon as I get home. Thanks for posting.



[ Reply to This | # ]
Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
Authored by: Geobunny on May 14, '12 04:53:16AM
This still works with Xcode 4.3.2 from the AppStore - the version where everything is self-contained in an App bundle. As in the original hint, install Xcode 3.2.6 first* and then download Xcode 4 from the AppStore.
Then do the following symlink magic:
  • cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
  • ln -s /Developer/Xcode3.2.6/SDKs/MacOSX10.5.sdk .
  • cd /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/
  • ln -s /Developer/Xcode3.2.5/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g* .
  • mv powerpc-apple-darwin10-llvm-gcc-4.2 powerpc-apple-darwin11-llvm-gcc-4.2
  • mv powerpc-apple-darwin10-llvm-g++-4.2 powerpc-apple-darwin11-llvm-g++-4.2

The last two lines rename darwin10 to darwin11 in the symlink - I'm guessing future versions of OS X will require this to be updated as appropriate.

* To install Xcode 3.2.x on Lion, mount the Xcode disk image, open Terminal, enter the commands (using bash, or the equivalent commands if you've changed your default shell):
  • export COMMAND_LINE_INSTALL=1
  • open "/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg"
You'll also need to set the clock back to a date prior to 31st March 2012 otherwise security certificates will fail validation during installation. You can safely change the date back again after installation obviously!

[ Reply to This | # ]
Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
Authored by: ctwise on Mar 19, '11 06:59:47AM

Actually, it _was_ done for technical reasons. Not because it wasn't possible to do it, but because they didn't want to spend technical resources to support and maintain it.

Apple seemingly can do more with their technical staff then other companies because they're ruthless about leaving technologies behind. When they decide they've gotten all the distance out of something, they drop it and it slowly starts to bit rot.

Will this work for XCode 4? Sure. And probably for 4.1. And maybe for 4.2. Possibly for 4.3. Until it stops working. And you have no recourse when it does stop working. So plan accordingly.



[ Reply to This | # ]
CPAN module PPC dependencies and Xcode4
Authored by: mbaudis on Mar 20, '11 02:32:40PM

I just ran into the missing PPC compiler option during a CPAN Perl module installation dying because of lack of PPC support through the compiler. There, I manually installed the module (MIME-Base64) by removing the -ppc compiler requirements from the makefile. I suppose this will lead to headaches for a while ...



[ Reply to This | # ]
Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
Authored by: jsenn on Mar 21, '11 10:06:53AM
If you want command line support (e.g from Terminal) you'll also need to:

cd /usr/libexec/gcc/powerpc-apple-darwin10/4.2.1
sudo mv as as.bak
sudo ln -s /Xcode3/usr/bin/as .


[ Reply to This | # ]

Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
Authored by: Mecki78 on Mar 22, '11 03:20:22AM

Yes, that is correct. Thank you for that valuable comment :-)



[ Reply to This | # ]
Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
Authored by: .max on Jun 25, '11 02:50:20PM
For a complete PPC support I'd also recommend editing this file:
/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX Architectures.xcspec

And adding this text to the list in that file:

{
	Type = Architecture;
	Identifier = ppc;
	Name = "Minimal (32-bit PowerPC only)";
	Description = "32-bit PowerPC";
	PerArchBuildSettingName = "PowerPC";
	ByteOrder = big;
	ListInEnum = No;
	SortNumber = 201;
},
 
That way PPC arch will be in the build settings. I've been using every release of Xcode 4 with 10.5+i386/ppc project for a year now no problem.

[ Reply to This | # ]
4.2 PPC needs one more step?
Authored by: thinkyhead on Jul 29, '11 01:51:47PM

Thank you for a most excellent tip! I found that I needed to create the /Developer/usr/libexec/gcc/powerpc-apple-darwin10 folder because it didn't exist. And it looks like Step 5 should include the following shell code, but maybe this is superfluous? :


  mkdir -p /Developer/usr/libexec/gcc/powerpc-apple-darwin10
  cd /Developer/usr/libexec/gcc/powerpc-apple-darwin10
  sudo ln -s /Xcode3/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1 .
---
|
| slur was here
|


[ Reply to This | # ]
Need an Xcode before 3.2.6
Authored by: thinkyhead on Jul 29, '11 02:24:58PM
According to Jason Kenney (in the Stack Overflow thread) version 3.2.6 of XCode doesn't include a version of as that supports the PPC architecture. So apparently you'll need to download a copy of XCode 3.2.5 and extract the file /usr/libexec/gcc/darwin/as using something like Pacifist.
---
|
| slur was here
|


[ Reply to This | # ]
Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
Authored by: negritude on Aug 07, '11 01:05:16AM

Installing Xcode 3.2.6 in Mac OS X Lion (10.7)
http://catacombae.blogspot.com/2011/07/installing-xcode-326-in-mac-os-x-lion.html



[ Reply to This | # ]
Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
Authored by: thinkyhead on Aug 11, '11 10:08:07PM

I've gathered together all the information from this page, Stack Overflow, splhack.org, and the other sources cited here, and put together a set of BASH scripts which automate the process of restoring PPC and GCC 4.0 support using either an XCode 3 installation or just XCode 4's own iPhone platform files.

As always, use with caution! and please contribute any fixes or improvements. These scripts have only been tested on my own system as of this posting.

The repository is hosted at:

---
|
| slur was here
|


[ Reply to This | # ]
Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
Authored by: leonardo on Sep 16, '11 10:00:04AM

I have done everything here specified for 10.5 SDK, but when I compile I still get the errors:
Stdarg.h: No such file or directory
Float.h: No such file or directory
Xmmintrin.h: No such file or directory
Expected specifier-qualifier-list before '__m128'
In file included from /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h
In file included from /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h
In file included from /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h
etc etc...



[ Reply to This | # ]
Uninstalling Xcode 4.3.2?
Authored by: Iriasm on May 22, '12 01:45:26PM

I need to have gcc 4.0 to work with Matlab R2010a, so I want to install an earlier version of Xcode, but I have already the latest Xcode installation in my Mac OSX 10.7.3. How do I uninstall the latest (4.3.2) Xcode version if I downloaded it from the app store? As posted here this is now an .app bundle (no /Developer folder or the like) and I cannot find the uninstall script anywhere within the bundle. Do I just trash the whole .app bundle from the applications folder? will this completely remove it?



[ Reply to This | # ]