Saturday, July 17, 2010

Managing Multiple Installations of Xcode

If you are developing for the iPhone you will quickly discover the need to support multiple installations of Xcode. The most common case is when you want to install the latest "beta" SDK to try out the hot new features while maintaining the latest "official" SDK for production purposes.

Supporting side by side installations is relatively simple but may not be immediately obvious if you haven't done it before. Several screens into the Xcode installation wizard, on the "Installation Type" page, there is a subtle drop down dialog for Location that lets you choose where to install. The default is /Developer but you can change it to what ever you like.

Many developers choose to always install the latest official release in the default location /Developer and the latest beta release in something such as /DeveloperBeta. Each time a new version is put out they upgrade the appropriate one.

I started out doing it this way but occasionally found it limiting to not have the older SDKs:

  1. Can't rebuild an old release of your product that was made with an old SDK
  2. Can't test using an old version of the simulator
  3. Can't compare differences in behavior between older SDKs / simulators
  4. Apple may release a broken SDK or you may not realize the consequences of upgrading the SDK. That may result in you needing to spend time uninstalling the new and reinstalling the old.
Starting tonight I'm trying out a new installation scheme. I'm now installing each new version (whether it is release or beta) to /iSDKs/[version_number]/ and simply ignoring the default /Developer location.

One point worth noting is that it turns out not all of the developer tools get placed in the location you choose! The fine print of the installer says that "System Tools" and "Unix Development" can only be installed once and are always installed to /Developer and the boot volume.

One important implication of this is that when you uninstall the version at /Developer you may also remove the single installations of "System Tools" and "Unix Development" which could cause problems with your other installations or build scripts. This is exactly what I did tonight and immediately discovered that version control in the other Xcode installs broke because it couldn't find cvs.

The main take away from this is that if you go down this route the order you install / uninstall can be important. I recommend:
  1. uninstall your current installations first (especially the one at /Developer)
  2. install each version one at a time proceeding from the oldest to the newest
P.S. The way to uninstall an XCode install is:
sudo [xcode-install-dir]/Library/uninstall-devtools --mode=all

If you use macports you will need to update the "developer_dir" setting in macports.conf (usually /opt/local/etc/macports/macports.conf) to point to the version it should use. I set it to /DeveloperCurrent and created a symlink there to point to the most recent release version.

No comments: