views:

259

answers:

1

I'm building an app which is a universal iPhone/iPad app. I'd like to support fast app switching (multitasking) with iOS 4.0 SDK (eg: on iPhone 3GS with iOS 4.0). However, when I set the app to build targeted to iPhone OS 4.0, it will not launch on the iPad (which currently latest software version is 3.2.1)

So it appears that the version of the SDK is the minimum OS version that the app will launch with.

The notes for the "iPhone OS Deployment Target" field in XCode settings state: "Code will load on this and later versions of iPhone OS. Frameworks APIs that are unavailable in earlier versions will be weak-linked; your code should check for null function pointers or specific system versions before calling newer APIS."

This seems contradictory. If it won't launch on an earlier API, how can it weak link to a null pointer?

Ultimately, I want to know: Can I build an app that is a universal app and supports multitasking (given that iPad OS is at 3.2)?!?

+2  A: 

Set your build SKD to iOS 4 but your deployment target to iOS 3.2. (I'd recommend creating 3.x compatible iPhone apps, but that's another story). This way multitasking is enabled but you say that the code also runs under 3.2, which Apple and your iPad will believe and run the thing.

Be careful however that you must therefore check yourself whether certain methods already exist under 3.2 since the compiler now will no longer warn you (since it builds against 4.0)! Most popular is the error to call [[UIScreen mainScreen] scale], which is not available under 3.2 and therefore your app will crash. You must check first whether this is supported:

CGFloat myScale = 1.f;
if ([UIScreen instancesRespondToSelector:@selector(scale)]) {
    myScale = [[UIScreen mainScreen] scale];
}
Pascal