Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to target a specific iPhone version?

Tags:

iphone

I've got some code I want to only execute on the latest iPhone SDK (3.0), however I can't seem to figure out a way to target just 3.0 and ignore 2.2.1 etc. There is an ifdef statement, but it just seems to cover the entire iPhone:

#if TARGET_OS_IPHONE 

Any help is appreciated.

like image 536
Oliver Avatar asked May 04 '09 13:05

Oliver


People also ask

How do I change my target iOS?

Select pods from the drop-down menu. Build settings may be found by selecting each project and target and clicking on them. Change the iOS Deployment Target version from 8.0 to anything higher than 8.0 in the Deployment subsection (better to try the same project version).

What iOS deployment target should I choose?

Suggested approach: Unless you have specific needs, a safe answer is Apple's: “the current version minus 1.” Note that e-commerce companies – i.e., companies that rely on users buying things through their app – are more likely to support a wider range of deployment targets, because even if only 5% of their users are on ...

How do I change the minimum iOS version?

The minimum iOS version is the lowest iOS version supported by your app. Users running an older iOS version will not download newer updates of your app from the app store. The minimum iOS version can be set in the build settings under iOS Deployment Target. The same counts for macOS, tvOS, and watchOS.

What is iOS development target?

That is the iOS deployment target or the minimum deployment target for iOS. It means that the application runs on any iOS device with iOS 14.3 or later installed. The values the dropdown menu lists depend on the version of Xcode you are using. Xcode 12, for example, no longer supports iOS 8.


1 Answers

You can use this #define to change what you build for each SDK...

#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_2_2 // iPhone 3.0 code here #endif 

And do this at run-time to run code for 3.0 and above:

float version = [[[UIDevice currentDevice] systemVersion] floatValue]; if (version >= 3.0)     {     // iPhone 3.0 code here     } 
like image 115
Jane Sales Avatar answered Sep 30 '22 17:09

Jane Sales