The problem with __IPHONE_3_0
and the like is that they are defined even if targeting other iOS versions; they are version identification constants, not constants that identify the target iOS version. Use __IPHONE_OS_VERSION_MIN_REQUIRED
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0
#elif __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0
#else
#endif
or even:
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
#elif __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000
#else
#endif
to get around the bug mentioned in the comments for "How to target a specific iPhone version?" __IPHONE_OS_VERSION_MAX_ALLOWED
might also be of use, in limited circumstances.
And, yes, it doesn't matter what device the app will run on. These constants are defined by the compiler and don't exist on the devices. Once the pre-processor runs, no macros are left. Though there are differences in the devices themselves, the iPhone and iPad both run iOS, and that's what you're really targetting.