12

Is it possible to write apps that support iOS 3.x versions using Xcode 4? If so, how? And does Apple have any official recommendations on app backwards-compatibility?

jrdioko
  • 32,230
  • 28
  • 81
  • 120

4 Answers4

22

To get your app successfully run in iOS 3.x device, follow these steps (Xcode 4.2):

  1. Click on your project name, select your Target and under "Build Settings"

    a) Set "iOS development target" (under "Deployment") to 3.0

    b). Add "armv6" to list of "Architectures" (under "Architectures").enter image description here

    c) Set "Other Linker Flags" (under "Linking") to "-weak-lSystem".

  2. In your Info.plist file remove value of "armv7" from "Required device capabilities" (UIRequiredDeviceCapabilities).

  3. In your code:

    a). Do not use userInterfaceIdiom. If you need to know, what device is it (iPhone or iPad), see How does one get UI_USER_INTERFACE_IDIOM() to work with iPhone OS SDK < 3.2.

    b) Do not use window.rootViewController. Instead use [window addSubview: self.mainViewController.view]; to add your main controller's view to window.

  4. Click on your project name, select your Target and under "Build Phases" / "Link Binary With Libraries" set "UIKit.framework" to "Optional". Also set to optional any extra framework, which is not available in iOS 3. For example, if you're using iAd or Twitter frameworks they should be set to optional. Check availability of extra framework in your code before use.

  5. When run on real device, compile app against last version of SDK. To do so, select second item from "Scheme" drop down (otherwise you'll get compile error related to your optional SDKs):

enter image description here

Community
  • 1
  • 1
Mike Keskinov
  • 11,614
  • 6
  • 59
  • 87
  • Thank you! I'm using XCode 4.2 with iOS SDK5, and for step 3B, I got my app working by replacing `self.window.rootViewController = self.viewController;` with `[self.window addSubview: self.viewController.view];` in AppDelegate.m – Chad von Nau Feb 12 '12 at 01:51
  • 1
    @MikeKeskinov I followed the steps above in Xcode 4.2.1 for Lion and it works. If I open the same project in Xcode 4.3, I encounter the same error that I was having before: an exception is thrown when the app tries to load the MainWindow nib saying: "-[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x4e, 0x49, 0x42, 0x41, 0x72, 0x63, 0x68, 0x69)'". Any suggestions? I'm stuck right now, so all ideas are appreciated. – Roberto Feb 25 '12 at 00:52
  • Use: [self.viewController.view setFrame: [[UIScreen mainScreen] applicationFrame]]; in AppDelegate.m, to work around the black gap in bottom – Noureddine AMRI Apr 30 '12 at 10:55
4

Yes, you can develop apps that support previous iOS versions with the current iOS SDK.

For official recommendations, see Apple's SDK Compatibility Guide.

Kristopher Johnson
  • 81,409
  • 55
  • 245
  • 302
2

The version of Xcode that you use isn't related to the version of iOS that your app can support. To choose the version of iOS that your app supports, simply change the iOS deployment target in your project settings. Then just be sure not to use any APIs from versions later than that.

GendoIkari
  • 11,734
  • 6
  • 62
  • 104
  • Also: anecdotally, Apple are no longer accepting apps with deployment targets earlier than 3.1; it's likely they'd have been requiring 4.0 by now but for the desire to allow developers to support the iPad's iOS 3.2 in universal apps, given that the iPad wasn't upgraded to iOS 4 for quite a while. If that helps at all with the "... does Apple have any official recommendations" part of the question. – Tommy May 20 '11 at 16:56
  • Apple support apps with development target 3.0 and above (see [here](http://stackoverflow.com/questions/5842178/minimum-ios-target-version-that-apple-accepts-in-appstore)). – Mike Keskinov Jan 07 '12 at 12:39
1

to be sure, you can use Xcode 4 for targeting iOS 3.x as a deployment target, but you will not be able to simulate your program on a iOS 3.x SDK simulator. So you are pretty on your own (i.e., if you use any iOS 4.x-only feature, you will not find out it until you test on a physical device).

You need an older version of Xcode to debug against an older simulated SDK.

sergio
  • 68,819
  • 11
  • 102
  • 123