10

I'd like to ensure some backward compatibility for my apps by compiling them using the older SDKs to test for newer classes and methods. However, Xcode is only available with SDKs for the latest iOS versions.

I've downloaded and installed the iOS 3.1.3 SDK (using the method described here) and that works fine. My code is full (not so full :-) ) of __IPHONE_OS_VERSION_MAX_ALLOWED, __IPHONE_OS_VERSION_MIN_REQUIRED and such respondsToSelector.

This works right now for the iOS 3.1.3 SDK, but what if in the future I wanted to repeat this process with the 4.0 SDK? Is there a general process for installing older SDK versions in the latest Xcode?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Oliver
  • 23,072
  • 33
  • 138
  • 230
  • Previously answered [here](http://stackoverflow.com/q/3027120/154803) – progrmr Sep 06 '11 at 13:51
  • 1
    @progrmr : I don't see where it is mentionned a way to install SDK 3.2 or SDK 4 on a XCode 4 with a 4.3 SDK installed. – Oliver Sep 06 '11 at 15:07
  • 1
    check out this post: http://stackoverflow.com/questions/7145001/upgrading-xcode-4-0-1-to-4-1-giving-compilation-error-for-iphone-sdk/7145080#7145080 – Daniel Sep 06 '11 at 17:25

2 Answers2

11

You can't install old 3.1 SDKs on Xcode 4. You can set the Deployment target lower to allow testing on devices running older OS versions than your current SDK installation. The only current way to completely ensure backward compatibility, while running more recent versions of Xcode, is to keep a device that runs iOS 3.x, and test on that device. (...because it is claimed that the old Simulators/tools sometimes actually allows APIs that won't run on an actual device with an OS of the same version).

Other methods include installing the different versions of iOS developer tools in a separate Developer_XYZ directories, and or keeping around a bootable HD with the older iOS developer tool installation (say Snow Leopard with Xcode 3.x, since Lion might only support running Xcode 4.x).

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • 3
    Then there is a company around whose name start with a A that really really sucks. Not supporting at least 4.0 SDK since iOS 5 is not out is just incredible ! – Oliver Sep 06 '11 at 17:25
  • 1
    @Oliver - What are you talking about? The current stable version of Xcode 4, 4.1, comes with the iOS 4.3 SDK. How could anyone submit anything to the App Store if they didn't support the current version of the OS? If you're talking about the beta for Xcode 4.2, did you read the first paragraph under "Xcode" in the release notes: http://developer.apple.com/library/prerelease/ios/#releasenotes/General/RN-iOSSDK-5_0/_index.html ? – Brad Larson Sep 07 '11 at 15:26
  • @Brad Larson : I mean that all versions of XCode since iOS 5 is not out should include at least a way to support iOS 4.0 coding : including the 4.0 SDK to be able to compile and check any 4.1 or 4.2 call, or make the compiler able to warn you about such calls. If it doesn't what is the need to specify an iOS target in the project prefs ? Just to put it on the AppStore ? – Oliver Sep 07 '11 at 16:22
  • @Oliver - Apple directly supports the current shipping OS version in the SDKs it releases. All devices that can run 4.0 can run 4.2, so there is no need to support down to that older version, and there is very little that is different between 4.3 and 4.2. Beyond methods, there are other more subtle aspects that change between the OS versions, so the only way you can guarantee compatibility with an OS version is to test your application against it using a device running that version. Trusting the Simulator and compiler is not enough. – Brad Larson Sep 07 '11 at 16:29
  • 1
    @Brad Larson : I'm ok that testing on the device must be done. But it's just the end of the process. Do you work with a team ? Do you tell each member that can be all around the world to call you each time the app crash because of a "too-new" call and because you don't have 3 monthes to check each code call by hand ? Do you have thousands of downloads ? If so, do you agree forgetting something like half iOS users that did not updated their device, because they can't, or because they don't want or don't knwo how to do (may I talk about the battery problem that appeared with iOS 4.3) ? – Oliver Sep 07 '11 at 16:52
  • @Oliver : Usually testing an app on the device is not done just at the end of the process, but as an on-going part of development. As for pre-checking each API call against the Deployment target OS version, there's probably a business opportunity here for some tool developer. – hotpaw2 Sep 07 '11 at 17:50
  • @hotpaw2 : more seriously, I mean that when you have an app that is already on sale, with tons of code, testing on the device is done at "the end" if you want to add some backward compatibility. – Oliver Sep 07 '11 at 18:29
6

For whatever reason (I had to do it to debug an Apple bug), if you still need to install an older SDK to your existing Xcode, follow these steps :

  • Install the older Xcode package
  • Copy the older Xcode SDK to the new Xcode Example (/old/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk to /new/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs)
  • Restart your 'new' Xcode
  • You will see the old SDK in the build setting option (base sdk)
Mustafa
  • 5,307
  • 1
  • 20
  • 19