Friday, July 22, 2011

Installing Xcode 3.2.6 in Mac OS X Lion (10.7)

Apple has decided to only ship Xcode 4.1 for Mac OS X Lion and disallow any earlier versions. Unfortunately this limits the resulting binaries to Intel macs and the Mac OS X 10.6 SDK. Developers that are still interested in supporting PowerPC Macs and/or Mac OS X 10.4 / 10.5 are left behind.

So here's a quick script that you can use to install Xcode 3.2.6 on Lion:
 Install Xcode 3.2.6 on Lion.command
Just extract the zip file, put the resulting script file, 'Install Xcode 3.2.6 on Lion.command' in the same directory as the downloaded disk image 'xcode_3.2.6_and_ios_sdk_4.3.dmg' and double-click 'Install Xcode 3.2.6 on Lion.command'.

Also, here are step-by-step instructions in case the script above doesn't work for you:


  1. Download the Xcode 3.2.6 disk image, 'xcode_3.2.6_and_ios_sdk_4.3.dmg', (I will assume it's in ~/Downloads for the next steps).

  2. Open up the Terminal and change to the directory where the image resides:
    cd ~/Downloads

  3. Attach the disk image with a shadow image to make it writable. Terminal command (as one line):
    hdiutil attach -shadow xcode_3.2.6_and_ios_sdk_4.3.shadow xcode_3.2.6_and_ios_sdk_4.3.dmg

  4. Remove the string '&& system.compareVersions(my.target.systemVersion.ProductVersion, '10.7') < 0 ' from line 148 in 'Xcode and iOS SDK.mpkg/Contents/iPhoneSDKSL.dist'. Assuming the disk image got mounted at '/Volumes/Xcode and iOS SDK', you can use this one-liner:
    cat '/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg/Contents/iPhoneSDKSL.dist' | sed "s/&& system.compareVersions(my.target.systemVersion.ProductVersion, '10.7') < 0 //g" > '/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg/Contents/iPhoneSDKSL.dist.new' && mv '/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg/Contents/iPhoneSDKSL.dist.new' '/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg/Contents/iPhoneSDKSL.dist'

  5. Install Xcode!

You can install Xcode 4.1 and Xcode 3.2.6 side-by-side, by choosing a different directory than '/Developer' as the install target for Xcode 3.2.6 (I use '/Xcode3.2'). However you can only have one global set of development tools installed (the ones that are installed in '/usr', i.e. are available for command line development).

Update: Xcode 3.2.6 can also be installed in Mountain Lion, but one very important point is to uncheck "System Tools" when installing. "System Tools" contain kernel extensions for profiling which are incompatible with the Mountain Lion kernel and will cause the system to panic on startup.
In addition, you will probably want to remove the kext AppleProfileFamily.kext in Mountain Lion because it cannot be loaded and causes annoying error messages on startup.

26 comments:

mazen said...

It looks great but unfortunately it is not working with me, as these two commands are not found

xcode_3.2.6_and_ios_sdk_4.3.shadow
xcode_3.2.6_and_ios_sdk_4.3.dmg

Erik said...

mazen:

Those two are part of a single line. Unfortunately the blog layout splits the lines rather unfortunately.

So all commands should be entered as single line.

mazen said...
This comment has been removed by the author.
mazen said...

You are the man :) thanks alot... it works for me now... I searched Google for the past 2 days and I haven't solution apart from yours... cheers you made my day

Anonymous said...

well done! Thank You!

Carl Petersen said...

Thanks, nice timesaver...

Eduardo Nunes Pereira said...

Thanks man ! you kick asses !

Sree said...

Wow!! saved so much trouble.. Thanks very much.

Regards Sree

Art said...

Restoring PPC, SDK 10.4/10.5 and GCC 4.0 Support to Xcode4
http://hints.macworld.com/article.php?story=20110318050811544

Cristian C said...

Great sir, seems to work perfectly!!!!

Anonymous said...

Seemed promising and must work, but not for me though :( It all installs ok, but if have a project or even make a new project, I keep getting the message "The document “****.xcodeproj” could not be saved.

If anyone has any thoughts it would be much appreciated. If not, I'll have to bite the bullet and go onto using a version 4 of Xcode.

James

uglybugger said...

Thank you! This has solved my problem after *hours* of messing about with an apparently-broken installer.

Anonymous said...

Thank you @@@@@@@

Anonymous said...

Thanks...!!
It helped me very much after messing with it for Hours.

Anonymous said...

Thanks it worked very well.

Monu said...

I tried to execute the command which have mentioned, but the installation failed towards the end

Also, I manually clicked on dmg file to install, but it doesn't create the SDKs folder

Anonymous said...

You can add the Mac OS X 10.7 SDK to Xcode 3.2.6.

The 'xcode_4.1_for_lion.dmg' image downloadable from connect.apple.com installs a 'Install Xcode.app' application into /Applications. You should also end up with the same application if you download Xcode 4.1 from the App store.

View the 'Install Xcode.app' package contents and navigate to Contents/Resources/Packages and install the 'MacOSX10.7.pkg' (just double-click it). When the Installer opens, be sure to click 'Change Install Location...' then you MUST click on one of the hard disk icons above and a 'Choose Folder...' button will appear. Click the 'Choose Folder...' button and pick your /Developer folder where Xcode 3.2 is installed.

It turns out that the MacOSX10.7.pkg installs an SDK that only requires Xcode 3.2 or later (and hence can be installed on either 10.6 or 10.7).

Ranorex4Beginers said...

It seemed to worked for me as well in the beginning. But in the middle it is asking for "xcode & sdk" disk to continue the installation.
Note: I have put the dmg file and the " Install Xcode 3.2.6 on Lion.command" inside a folder.
then i executed the "Install Xcode 3.2.6 on Lion.command" file and the installation process started. the xcode option got checked by default [which looks great] but atlast it is asking for the cd.

What should i do?

Note: i had already installed the sdk but the xcode was not installed as it does not support.

Ranorex4Beginers said...

Hi Eric !
Atlast i got xcode installed in my machine.. thank you very much.

I have another problem and searching for the solution from last 3 days but i did not get. I hope you may have some solutions.

Here is the issue::::
I want to know whether we can install an app in iphone simulator without having source code.

My Scenario [in detail]
I have installed iphone simulator by downloading "xcode_3.2.6_and_ios_sdk_4.3.dmg" in Mac OS.

points to be noted:
1. Iam not a developer. Iam a tester and i just want to install iphone simulator and some free app into it and just want to play with it.
2. I dont have any itunes account.
3. I have iphone developer account through which i downloaded "xcode_3.2.6_and_ios_sdk_4.3.dmg"

Now, the question is :::
Is it possible by any means that i can able to install some free app in my iphone simulator?

Its very urgent Erik. Could you please reply As Early As Possible...

Thankyou so much

Hrusi said...

This just works!! Gr8!!

It also opened my eyes towards Mac softwares in general. Life here is no different then Windows world. :)

Venkatesh.S said...

Hi Erik,

How can i install the xcode_3.2.6_and_ios_sdk_4.3.dmg in "windows-xp"

i had tried last 2 or 3 days, could you please help me on that.

Thanks,
Venkatesh.S

Ali said...

hay Eric is ill it work if i install xcode 3.2.5 and ios sdk 4.2??????

xmlnovelist said...

Can't get this installer to run no matter what. Keeps hanging with an Alert saying iTunes is running.

Mar 22 20:24:39 theidiot installd[690]: ./preinstall: 2012-03-22 20:24:39.608 AlertAll[939:b07] >> timerMethod
Mar 22 20:24:39 theidiot installd[690]: ./preinstall: 2012-03-22 20:24:39.610 AlertAll[939:b07] >> updateTable
Mar 22 20:24:39 theidiot installd[690]: ./preinstall: 2012-03-22 20:24:39.611 AlertAll[939:b07] /AppleInternal/Applications/PurpleRestore.app
Mar 22 20:24:39 theidiot installd[690]: ./preinstall: 2012-03-22 20:24:39.680 AlertAll[939:b07] /Applications/iTunes.app
Mar 22 20:24:39 theidiot installd[690]: ./preinstall: 2012-03-22 20:24:39.748 AlertAll[939:b07] /var/folders/1z/pttgp2sn24s_6yrrm7_l8wj40000gn/T/xcodelion.fyQbOP0c/Packages/MobileDevice.pkg/Applications/Xcode.app
Mar 22 20:24:44 theidiot installd[690]: ./preinstall: 2012-03-22 20:24:44.609 AlertAll[939:b07] >> timerMethod
Mar 22 20:24:44 theidiot installd[690]: ./preinstall: 2012-03-22 20:24:44.611 AlertAll[939:b07] >> updateTable
Mar 22 20:24:44 theidiot installd[690]: ./preinstall: 2012-03-22 20:24:44.612 AlertAll[939:b07] /AppleInternal/Applications/PurpleRestore.app
Mar 22 20:24:44 theidiot installd[690]: ./preinstall: Can't tget thsi 2012-03-22 20:24:44.680 AlertAll[939:b07] /Applications/iTunes.app
Mar 22 20:24:44 theidiot installd[690]: ./preinstall: 2012-03-22 20:24:44.750 AlertAll[939:b07] /var/folders/1z/pttgp2sn24s_6yrrm7_l8wj40000gn/T/xcodelion.fyQbOP0c/Packages/MobileDevice.pkg/Applications/Xcode.app

wolverine said...

Thanks Erik

Some times we mght need to stop itunerhelper with activity monitor or ps & grep & kill

Raj said...

Excellent! post.
spent days to make it work with other URLs from google, youtube etc .... until i got this one :)

Anonymous said...

Hi Eric,

Thanks a lot for this post & it worked for me except one thing. I am keep getting the message "The document “****.xcodeproj” could not be saved.

Any idea please?

Regards
Gurmeet