20

I just installed Lion and Xcode 4.1. How do I add older SDKs so I can build and run in 4.1 or 4.2 in iPhone/iPad Simulator? Xcode 4.1 only comes with the iOS 4.3 SDK.

Does Lion have some sort of minimum SDK for builds?

Thanks,

0

8 Answers 8

27

Actually it is possible to add older SDKs as long as you can still get your hands on an older version of Xcode with the older SDK. It's useful too sometimes: when you do this you get to find out about unsupported constants and methods you may be using during compile rather than at runtime. Here's how to do it.

  1. Get hold of an older version of Xcode with the older SDK. The Apple iOS Dev Center currently lists the 4.3 SDK with the Xcode 3.2.6 download.

  2. Mount the dmg and open up the Packages folder hidden within the dmg via Terminal:

    open /Volumes/Xcode\ and\ iOS\ SDK/Packages/

  3. Double click the pkg file for the SDK version you want. I was looking for iPhoneSDK4_3.pkg but, in addition to 4.3, found packages as old as iPhoneSDK3_0.pkg. So perhaps older SDKs may still be packaged with the App Store download if you know where to find it (I didn't).

  4. Let it install in it's own folder of choice since you won't be able to force it to install in Applications/Xcode.app/Contents/Developer (which is where the Developer folder is now)

  5. You'll find the package installed in the Platforms folder in the volume you chose. Move the relevant SDK over to the Developer folder within Xcode.app. You'll likely have to use sudo:

    sudo mv /Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

  6. Restart Xcode and you should see the new (old) SDK listed in your options for Base SDK. Yay!

Update as of 12 Sep 2013

If the "older SDK" you're trying to add comes bundled in Xcode 4.3 or later, adding the SDK is as simple as downloading Xcode from dev center link that says "Looking for an older version of Xcode?" (currently points here), mounting the dmg, then copying the relevant files over.

In terminal, you'd do something like this (edit for the appropriate SDK version number):

cp -R /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

For SDKs from versions of Xcode prior to 4.3, the older steps are still relevant.

I found this happens to work for getting the Xcode 5 GM to compile builds that carry the old iOS 6 UI even when deployed on iOS 7 devices. Useful for fixing bugs pending a UI redesign. That said, there's got to be an easier way to get the iOS 6 UI on an iOS 7 device.

4
  • ok i tried this on Lion 10.7.4 with xcode 4.3.3 to install iPhone5.0.sdk but xcode doesn't seem to recognize it. I have IOS 5 simulator running and I can set the BaseSDK to 5.0 but my iPad has 5.0.1 and nothing gets transferred there. In Snow Leopard no problem. All the certs are there on both systems. It's weird.. Jul 25, 2012 at 13:10
  • Any errors/warnings from xcode? Is your iOS Deployment Target version set correctly? Also ensure that armv7 is set as a valid architecture
    – nioq
    Jul 25, 2012 at 16:31
  • This even works for older version of the OS X SDKs. For example I was able to copy /Developer/SDKs/MacOSX10.5.sdk on my old build machine to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk on my new machine. Apr 17, 2013 at 1:35
  • I use this technique to get older SDKs compiling for ARMv6 code on Mountain Lion by running old XCode 4.4.1 and then using these techniques to copy SDKs from XCode 4.1
    – scotru
    Sep 5, 2013 at 7:36
8

You can't. What you can do, however, is click on the top-level entry in the File Navigator. It'll take you to the application settings. Go to the tab called Build Settings, and change the iOS Deployment Target to whatever version of iOS you'd like to support from (the earliest version you support).

See "To Edit a Build Setting…": http://developer.apple.com/library/ios/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Building/Building.html#//apple_ref/doc/uid/TP40010215-CH9-SW5

1
  • As seen in the anwer above, you can add additional SDK's as long as you have a copy of the older xcode which bundles it [or you simply have a copy of the older sdk and copy it to the correct location] Jun 11, 2014 at 20:34
8

Open Xcode and open Preferences (Xcode -> Preferences menu). Click the Downloads icon and look in the Components tab. All versions from 3.0 to 5.1 should be available. Just click Install for the ones you want to use.

6

None of these answers worked for me for Mac OS 10.8 and XCode 4.5. But now that things are installed under the Applications folder, it's much easier to manage.

Option #1: Keeping an older copy of XCode is easy to do by renaming it before you install the new one. Then you can use Product->Preform Action->Run Without Building on the new version to test on newer devices or newer simulators.

Option #2: If you REALLY want to build with older SDKs in the newer XCode, then you can simply copy over an SDK using finder. You'll need to have an older version of XCode installed under Applications for this to work. In the following example, I just renamed XCode 4.4 to XCode_old before I installed XCode 4.5. Note: You can right click on the .app file and choose Show Contents to get to these files or just use the cp from a terminal window.

from: /Applications/Xcode_old.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
to:   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

Then, iOS 5.1 will show up under Build Settings as a Bask SDK. You can do the same thing for simulators:

from: /Applications/Xcode_old.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk
to:   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/
1

You can't, but it will build fine for a device that is plugged in running an old version of iOS (what you should be conducting your proper testing on).

1

You have to run your application in the older version of Xcode that came coupled with the older iOS version. I have 3.2.5 installed under /Developer-3.2.5/. I have to say it's about 10 times faster than Xcode 4... You can download old versions here: http://iphonesdkdev.blogspot.com/2010/04/old-versions-of-iphone-sdk.html

3
  • Nothing older than what he has is supported on Lion. I'm in the same boat. I upgraded to Lion, and now I can't run any old simulators. Lame.
    – Nate
    Mar 1, 2012 at 10:48
  • Hmm, I'm not sure there. I had 3.2.5 lying around from snow leopard, but if it ran I imagine it's compatible. If it doesn't install it'd be a deliberate restriction I guess. Mar 1, 2012 at 10:54
  • Well, I'm pretty sure. For the first few weeks, Apple had an explicit disclaimer on the page linked to with "Looking for XCode 3?" that said that it wasn't supported on Lion. In case you're not familiar with how Apple works, they do stuff like this constantly to make sure you always have to upgrade to whatever their newest is (hardware and software).
    – Nate
    Mar 18, 2012 at 9:22
0

I had a similar issue in Xcode 4.02 for Snow Leopard using SDK 4.3. I wanted to test on an iPhone 3G, but iOS4.2 is the latest (and correct version) for that device. In order to 'see' and run on that device in the Scheme, I had to change the Build Settings for iOS Deployment Target as described above. (btw you also have to have restrictions on the iPhone turned off to let Xcode install the app :) )

0

In addition to Steven's answer, you can find older versions of XCode - including the older SDKs:

Looking for an older version of Xcode?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.