Wednesday, August 27, 2014

Chuck Norris-ing a .pkg installer into submission (Updated 28-11-2014)

Or: How to install Legacy Mac OS X SDKs for Xcode

As you explore open-source Mac software, you will eventually have to build for older versions of OS X.

But you will need older OS X SDKs.

The solution? Roundhouse-kick an old, defenseless Xcode installer into a bloody mess, of course! Then you can find all its subinstallers—including the legacy SDKs!

The easy way is to use Pacifist (shareware $20), which is a great piece of software designed to do exactly this sort of thing. If the Terminal scares you, I highly recommend it!

But, if you are a Terminal junkie, here is how I added the SDKs for 10.6 and 10.7, using only free software. The technique can really be applied to any .pkg installer.

Mac OS X 10.6 and 10.7 SDKs

  1. Download "Xcode 4.2.1 for Lion" from and mount the disk image.
  2. Now switch to the Terminal. From now on, commands inline with the paragraph text are optional and commands indented in code blocks are required.

    If you run file /Volumes/Install\ Xcode/InstallXcodeLion.pkg, you will see that the installer is a xar archive. To unpack it, run
    cd ~/Desktop
    mkdir Xcode421
    cd Xcode421
    xar -xf /Volumes/Install\ Xcode/InstallXcodeLion.pkg
  3. Now, run
    cd InstallXcodeLion.pkg
  4. Running ls -lh shows that Payload is the largest file. If we again run file Payload, we see that we have a gzip archive, which is in fact a tarball. Unpack it with
    mv Payload{,.tar.gz}
    tar -xf Payload.tar.gz
  5. Now run
    open Applications/Install\
    You will see a Finder window with all the sub-installers for Xcode. Score!
  6. Run MacOSX10.7.pkg, MacOSX10.6.pkg, then MacOSX10.6.Patch1.pkg from the Finder. (Hint: If you keep a previously-authenticated installer open after it completes, you can run the next installer without a password.)

    (Updated 28-11-2014:) If the system complains about the .pkg being from an unrecognized developer, you can open it anyway by right-clicking, and selecting open. This will give a different warning dialog, in which you have an "Open" button.
  7. Back in the Terminal, run
    cd /Applications/
    sudo mv /SDKs/*.sdk MacOSX.platform/Developer/SDKs/
    If it takes a while, you can hit ctrl-T to see the progress. That sends a SIGINFO signal to the frontmost process, which causes it to show what's happening.

And finished! If you try configuring a project to build in Xcode using the new SDKs, keep in mind that you may need to build for 32-bit architecture only.

Mac OS X 10.5 SDK

The older installers are a bit simpler. I think that this is because they didn't need to be packaged for the App Store like the new ones. Without further ado, we'll Chuck Norris this one too!
  1. Download "Xcode 3.2.6 and iOS SDK 4.3 for Snow Leopard" from and mount the disk image.
  2. Still in the Finder, with the window for the disk image in the front, hit Cmd-Shift-G and type "Packages" in the box.
  3. Double-click and install MacOSX10.5.pkg.
  4. In the Terminal, run
    cd /Applications/
    sudo mv /SDKs/MacOSX10.5.sdk MacOSX.platform/Developer/SDKs/

Bonus: Hiding and un-hiding files

That was pretty sneaky of Apple, hiding the Packages folder like that. If you want to be able to do that too, add these lines to your .bashrc:
alias hide='sudo chflags hidden'
alias unhide='sudo chflags nohidden'
And again, happy hacking!

PS: Older .pkgs (added 28-11-2014):

For even older SDKs, the installer might get in your way, since your system is too new. The answer is to Chuck Norris it some more.
  1. Copy the .pkg to a writeable location.
  2. Right-click and open the package contents.
  3. Go to Contents/Resources.
  4. Move VolumeCheck to the Trash.
  5. Right-click on the .pkg, and click Open. This lets you open it despite the package not being signed.

No comments:

Post a Comment