Building a Grand Unified Xcode 4.3 installer
Apple has released Xcode 4.3 through the Mac App Store for all Macs running 10.7.3 and higher. In a break from the “installing an installer” method that Apple used for Xcode 4.1 and 4.2, the App Store is now installing Xcode as a self-contained application. This application, on first launch, then installs the other Xcode tools. The command line tools can be installed separately through the Xcode preferences, in the Downloads section.
For my users who are developers, I wanted to include Xcode 4.3 in their new machine builds and also install the command line tools automatically. To do this, I used a modified form of the methodology referenced in this post to repackage Xcode 4.3 for distribution without needing an Apple ID. See below the jump for the procedure.
Building the package
Install Xcode 4.3 from the Mac App Store onto your build machine.
Download the latest Command Line Tools for Xcode disk image from the Apple Developer site
Verify that the permissions on the Xcode application in /Applications are correct by running the following command:
sudo chown -R root:wheel /Applications/Xcode.app
Set up a new Iceberg project. Since we’ll need to run this installer with root privileges, I recommend setting the project type to Darwin: Package. That will open the project with the installation privileges automatically set to root.
In this case, I’m naming the project Xcode 4.3.
In the Files section, click on the Applications folder in the listing.
Go to the Archive menu and select Add Files…
Select the Xcode application in /Applications
Verify that it’s now showing up under Applications in your Iceberg project
Select the Command Line Tools for Xcode disk image and drag it into the Additional Resources section of your Iceberg project.
The last pieces are removing any previous Xcode.app from /Applications and telling the Command Line Tools for Xcode installer to run.
To remove any previous Xcode.app from /Applications, I’m using the following preflight script:
# Remove existing /Applications/Xcode.app from machine
if [ -d /Applications/Xcode.app ]; then
sudo rm -rf /Applications/Xcode.app
To install the command line tools, I’m using the following postflight script:
# Create /tmp/Command\ Line\ Tools mountpoint in /tmp
/bin/mkdir /tmp/Command\ Line\ Tools
# Mount the command_line_tools_for_xcode_.dmg disk image as /tmp/Command\ Line\ Tools
/usr/bin/hdiutil attach "$1/Contents/Resources/command_line_tools_for_xcode.dmg" -mountpoint /tmp/Command\ Line\ Tools -nobrowse -noverify -noautoopen
# Install the Xcode command line tools
/usr/sbin/installer -dumplog -verbose -pkg "/tmp/Command Line Tools/Command Line Tools.mpkg" -target /
# Unmount the command_line_tools_for_xcode_.dmg disk image from /tmp/Command\ Line\ Tools
/usr/bin/hdiutil eject /tmp/Command\ Line\ Tools
# Remove /tmp/Command\ Line\ Tools from /tmp
/bin/rm -rf /tmp/Command\ Line\ Tools
Once you’ve got the preflight and postflight script built, run the following commands to make the scripts executable:
sudo chmod a+x /path/to/preflight
sudo chmod a+x /path/to/postflight
Last step, go ahead and build the package. (If you don’t know to build, check the Help menu for the Iceberg User Guide. The information you need is in Chapter 3 – Creating a package.)
Once the package has been built, test it by taking it to a test machine running 10.7.3 or higher that doesn’t have Xcode 4.3 and install it. The end result should be that Xcode 4.3 installs along with the command line tools without requiring an Apple ID.
I’ve tested this package both with a DeployStudio postponed install and as a Casper Self Service policy. In both cases, it worked well. Xcode installed properly and the command line tools showed up as installed.
For those who want to replicate this in Casper, there’s an additional script I’ve written named xcode_uninstall.sh which is used to uninstall prior Xcode installations before installing Xcode 4.3
# Uninstalls versions of Xcode prior to Xcode 4.3
sudo /Developer/Library/uninstall-devtools --mode=all
This script is set to run before the Xcode 4.3 installation. To make sure my users are aware that previous Xcode installs are removed, I’ve added this note.
My Self Service policy is set up as shown in the screenshots below.