1

I've searched around including the iOS SDK Compatibility Guide but cannot get an explanation of this.

I understand that:

  • Deployment target is the earliest OS version an App can run on
  • Base SDK is the SDK it will be compiled using and whose features can be used if the run time device supports them

What I'm struggling with is how __IPHONE_OS_VERSION_MIN_REQUIRED can be used when this is fixed at compile time and the device's OS is only known at run time. So the code that I submit will always compile the same.

Or are multiple versions compiled automatically?

Can someone please explain?

Many thanks,

Chris.

Chris
  • 1,449
  • 1
  • 18
  • 39

2 Answers2

1

You're right that __IPHONE_OS_VERSION_MIN_REQUIRED is fixed at compile time. Those contants and macros can become useful if you compile your application for different platforms and versions. So if you would compile one version of your app for iOS 3.0 and one for iOS 4.0 you could use __IPHONE_OS_VERSION_MIN_REQUIRED to remove all iOS 4.0 code from your iOS 3.0 version at compile time.

Since the AppStore forces you to use some recent SDK version, you're forced to use the 4.0 SDK even if you target 3.0 devices. __IPHONE_OS_VERSION_MIN_REQUIRED would only be useful when using and older SDK. Since you just can set the deployment target to a lower version, you'll have to check for the iOS version during runtime.

You can use the method described here to check the iOS version during runtime

Community
  • 1
  • 1
Konrad
  • 1,285
  • 21
  • 28
1

The IPHONE_OS_VERSION_MIN_REQUIRED is a define - so whilst your deployment target may be low, you may be using some important deprecated functions if your app is to be heavily compatible with a number of iOS versions.

You are - of course - correct in saying that the device's OS is only known at run time. Depending on your project settings, Apple will use that information on the app store to ensure that users with the correct device can access your software. Multiple versions are not created to my knowledge - the code that you submit will appear to be dynamic if you use that define to make the most of working with older iOS versions.

You may also find this useful:

How to target a specific iPhone version?

Community
  • 1
  • 1
Luke
  • 11,426
  • 43
  • 60
  • 69
  • Thanks @Krypton and @Konrad. The link above float the option to use [[[UIDevice currentDevice] systemVersion] floatValue] worked for me. I've also used respondsToSelector:@selector for distanceFromLocation. – Chris Jun 23 '11 at 15:42
  • Awesome to hear :) Watch out for rogue float values, as that topic link describes. – Luke Jun 23 '11 at 15:43