Apple has released Xcode 5.0 through the Mac App Store for all Macs running 10.8.4 and higher. The command line tools can be installed separately through the Xcode preferences, in the Downloads section. You now need an Apple Developer Connection account to install the Xcode 5 command line tools via the Xcode preferences, though a free ADC membership is sufficient.
For my users who are developers, I wanted to include Xcode 5.0 in their new machine builds and also install the command line tools automatically without needing to enter an Apple ID. I also wanted to build this installer as a flat package, so I’m shifting from my previous method using Iceberg to using Packages to build the installer package. See below the jump for the details.
Download Xcode 5.0 from the Apple Developer site and drag the application into /Applications.
Download the latest Mountain Lion Command Line Tools for Xcode disk images 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 Packages project and select Raw Package.
In this case, I’m naming the project Xcode 5.0.
Click on the Settings tab and set the following:
In the Post-Installation Behavior section, set On Success: to Do Nothing
In the Options section, check the box for Require admin password for installation.
Click on the Payload tab, then click on the Applications folder in the listing.
Go to the Hierarchy menu and select Add Files…
Select the Xcode application in /Applications
Verify that it’s now showing up under Applications in your Packages project.
Click on the Scripts tab in your Packages project.
Select the Mountain Lion Command Line Tools for Xcode disk image and drag it into the Additional Resources section of your Packages 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 preinstall script:
#!/bin/sh # Remove existing /Applications/Xcode.app from machine if [ -d /Applications/Xcode.app ]; then rm -rf /Applications/Xcode.app fi
To install the command line tools, I’m using the following postinstall script:
#!/bin/bash # Determine OS version osvers=$(sw_vers -productVersion | awk -F. '{print $2}') # Determine working directory install_dir=`dirname $0` if [[ ${osvers} -eq 8 ]]; then # # Installing the Xcode 5.0 10.8 Command Line Tools # # Create /tmp/Command Line Tools (Mountain Lion) mountpoint in /tmp /bin/mkdir "/tmp/Command Line Tools (Mountain Lion)" # Mount the latest command line tools disk image as /tmp/Command Line Tools (Mountain Lion) /usr/bin/hdiutil attach "$install_dir/command_line_tools_os_x_mountain_lion_for_xcode__september_2013.dmg" -mountpoint "/tmp/Command Line Tools (Mountain Lion)" -nobrowse -noverify -noautoopen # Install the Xcode command line tools /usr/sbin/installer -dumplog -verbose -pkg "/tmp/Command Line Tools (Mountain Lion)/Command Line Tools (Mountain Lion).mpkg" -target / # Clean-up # Unmount the command line tools disk image from /tmp/Command Line Tools (Mountain Lion) /usr/bin/hdiutil eject "/tmp/Command Line Tools (Mountain Lion)" # Remove /tmp/Command Line Tools (Mountain Lion) from /tmp /bin/rm -rf "/tmp/Command Line Tools (Mountain Lion)" fi
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/preinstall
sudo chmod a+x /path/to/postinstall
Once completed, add the preinstall and postinstall scripts to your Packages project.
Last step, go ahead and build the package. (If you don’t know to build, check the Help menu for the Packages User Guide. The information you need is in Chapter 3 – Creating a raw package project and Chapter 10 – Building a project.)
Once the package has been built, test it by taking it to a test machine running 10.8.4 or 10.8.5 that doesn’t have Xcode 5.0 and install it. The end result should be that Xcode 5.0 installs along with the Xcode command line tools without requiring an Apple ID.