Adding an old SDK to Xcode 4
I have read that you can have multiple SDKs in Xcode 4 installed in the Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs directory. What was not made clear is how you can get these different SDKs. I'd at least like to test for iOS 4.0 instead of the latest iOS 4.3. Though it would be cool to test for 3.2 also. My Xcode 4 installed only with the latest 4.3 SDK in this directory. Is there a convenient way to add them?
No there is not a convenient way, unfortunately. The easiest way is to install an earlier version and then upgrade it, progressively if necessarily, to the latest version.
When you install Xcode 4.0, your previous version get's renamed to something like "Developer-3.2.5". If you still have a previous version of Xcode installed you can simply do this:
cd /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs sudo ln -s /Developer-3.2.5/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk . sudo ln -s /Developer-3.2.5/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk .
If you don't have a previous version installed, uninstall Xcode 4.x and then install Xcode 3.2 and start progressively from there. After you install Xcode 4.x your previous version of Xcode 3.x will get renamed on disk after which you can symlink the 4.0/4.1 SDKs under Xcode 4.0. Relaunching Xcode 4.0 will give you 4.0 and 4.1 in the drop down option list.
The XCode downloads available from http://developer.apple.com/downloads appear to contain packages going back to before 4.0. I recently hit this same issue and was able to determine that:
- From 4.1 onward (Maybe earlier - still waiting for the download for XCode 3.2.3 and SDK 4.0.1), the packages contain sub-packages named quite similarly
- Despite the inner package name, it appears that the actual iOS SDK will be included for the version mentioned on the primary DMG file. For instance, xcode_3.2.5_and_ios_sdk_4.2_final.dmg may contain what appears to be SDK packages for a bunch of versions, but the iOS SDK is only fully included for 4.2.
- I was able to get my hands on 4.1, 4.2, and 4.3 by downloading the DMG XCode installers, viewing package contents, and running the corresponding iPhoneSDK4_X.pkg installer.
- After installing, I had to copy the stuff it dropped from /Platforms/iPhoneOS.platform/ into the new location at /Developer/Platforms/iPhoneOS.platform.
- In addition to the SDKs for iPhoneOS, I also made sure the iPhoneSimulator.platform stuff was there. For me, it seems that XCode handles installing most device support for debugging..
I hope this helps! The tricky part for me was realizing that the package names may be the same, yet the contents may be different. Each download only seems to have included a single full SDK.
Once I did this, i was able to change my base SDK in XCode and build against the target SDK.
PS: Once you add additional SDK's, you will likely see additional destinations appearing in your schemes list with identical device names for the physical devices. It drove me nuts, as each one is associated with one of the SDK's, yet the SDK version isn't listed in the list. Not bad once you figure out which is which, usually the symptom being a failed build, since it targets another SDK based on which physical device is selected. More info on this post: duplicate device scheme in xcode 4