The Definitive Guide to Installing Xcode 3 on Mountain Lion

(Without Kernel Panics)

May 5, 2013

Wow, two articles in two days. Don't expect this to become a habit.

You may find yourself needing to install Xcode 3 on Mountain Lion. I did. Perhaps you need the Mac OS X 10.6 SDK. Perhaps you need to build PowerPC code. Or perhaps you just hate the Xcode 4 GUI. In any case, the Xcode 3 installer won't allow you to install on Mountain Lion, and even if you force it with the environment variable COMMAND_LINE_INSTALL, your Mac will kernel panic on the next boot, because Xcode 3 installs some kernel extensions that are not compatible with Mountain Lion.

Lost cause, right? Never fear, Jeff is here! I've found a way to hack the installer to only give you the essentials, skipping the bad, kernel panicky junk. The first thing you need is the Xcode 3.2.6 installer, which is still available for download from here. Then make a copy of the installer on your Mac that you can edit:

$ cp -R /Volumes/Xcode\ and\ iOS\ SDK/ ~/Desktop/Xcode

In your installer copy, show the package contents of Xcode and iOS SDK.mpkg. You should see the file iPhoneSDKSL.dist in the package contents. Edit the file according to the following diff. You're mostly deleting lines, as well as replacing false with true.

$ diff -u /Volumes/Xcode\ and\ iOS\ SDK/Xcode\ and\ iOS\ SDK.mpkg/Contents/iPhoneSDKSL.dist ~/Desktop/Xcode/Xcode\ and\ iOS\ SDK.mpkg/Contents/iPhoneSDKSL.dist
--- /Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg/Contents/iPhoneSDKSL.dist	2011-02-18 22:55:02.000000000 -0600
+++ /Users/flynn/Desktop/Xcode/Xcode and iOS SDK.mpkg/Contents/iPhoneSDKSL.dist	2013-03-19 19:39:30.000000000 -0500
@@ -144,12 +144,7 @@
 		}
 		function isDevToolsCompatible()
 		{
-		    if ( system.env.COMMAND_LINE_INSTALL == 1 ) { return true; }
-		    if( system.compareVersions(my.target.systemVersion.ProductVersion, '10.6.6')  >= 0 && system.compareVersions(my.target.systemVersion.ProductVersion, '10.7') < 0 ) {
-			    
-			    return true;
-			 }
-		    return false;
+		    return true;
 		}
 	</script>
 
@@ -184,7 +179,6 @@
 			<line choice="DeveloperToolsSystemComponentsHIDDEN"/>
 		</line>
 		<line choice="DeveloperToolsSystemSupportHIDDEN"/>
-		<line choice="XcodeExtrasHIDDEN"/>
 		<line choice="XcodeExtrasHIDDENThree"/>
 		<line choice="UNIXDevelopmentSupport">
 			<line choice="UNIXDevelopmentSupportHIDDEN"/>
@@ -428,15 +422,6 @@
 	<pkg-ref id="com.apple.pkg.DeveloperToolsSystemSupport"/>
 </choice>
 
-<choice 
-	id="XcodeExtrasHIDDEN"
-	customLocation = '/'
-	customLocationAllowAlternateVolumes = 'YES'
-	start_visible='false'
->
-	<pkg-ref id="com.apple.pkg.Xcode_MacOSX10.6_Extras"/>
-</choice>
-
 <choice
 	id="XcodeExtrasHIDDENThree"
 	customLocation = '/'
@@ -540,8 +525,6 @@
 	<pkg-ref id="com.apple.pkg.llvm-gcc4.2" auth='root'>file:../Packages/llvm-gcc4.2.pkg</pkg-ref>
 	<pkg-ref id="com.apple.pkg.llvm-gcc4.2ROOT" auth='root'>file:../Packages/llvm-gcc4.2.pkg</pkg-ref>
 	
-	<pkg-ref id="com.apple.pkg.Xcode_MacOSX10.6_Extras" auth='root'>file:../Packages/Xcode_MacOSX10.6_Extras.pkg</pkg-ref>
-	
 	<pkg-ref id="com.apple.pkg.xcrun" auth='root'>file:../Packages/xcrun.pkg</pkg-ref>
 
 	<pkg-ref id="com.apple.pkg.MacOSX10.4.Universal" auth='root'>file:../Packages/MacOSX10.4.Universal.pkg</pkg-ref>
@@ -664,6 +647,5 @@
 	<pkg-ref id='com.apple.pkg.X11Documentation' installKBytes='6858'/>
 	<pkg-ref id='com.apple.pkg.X11DocumentationROOT' installKBytes='6858'/>
 	<pkg-ref id='com.apple.pkg.X11SDKForMacOSX' installKBytes='8406'/>
-	<pkg-ref id='com.apple.pkg.Xcode_MacOSX10.6_Extras' installKBytes='14742'/>
 	<pkg-ref id='com.apple.pkg.xcrun' installKBytes='182'/>
 </installer-gui-script>

As a result of these edits, the installer won't prevent you from installing on Mountain Lion, but it won't install Packages/Xcode_MacOSX10.6_Extras.pkg, which is incompatible with Mac OS X 10.8.

After you've edited the file, you can run the installer (open your copy of Xcode and iOS SDK.mpkg). It will ask to quit and reopen, because Installer starts as 64-bit, but it needs to run as 32-bit in order to install Xcode 3. It will also say that the signing certificate has expired, so you'll need to ignore that and continue. Install the "Essentials", and optionally, "UNIX Development". Do NOT install "System Tools", because that will install CHUD, which includes kernel extensions that will also cause panics on Mountain Lion.

When you've finished installing, and you try to run Xcode 3, it will ask to install Java, if Java is not already installed. I don't know why Xcode 3 needs Java, but it does. Also, you may find some broken symlinks in /Developer/usr/bin, but those are easy enough to fix. Finally, if you install the optional "UNIX Development", and you had previously installed the Xcode 4 "Command Line Tools" component, you'll want to reinstall that component, because Xcode 3 overwrites files in the same place.

It's no coincidence that my two articles so far are about backward compatibility with Snow Leopard. Apple doesn't make that easy. I do. You're welcome!