I want to check if the iOS
version of the device is greater than 3.1.3
I tried things like:
[[UIDevice currentDevice].systemVersion floatValue]
but it does not work, I just want a:
if (version > 3.1.3) { }
How can I achieve this?
I want to check if the iOS
version of the device is greater than 3.1.3
I tried things like:
[[UIDevice currentDevice].systemVersion floatValue]
but it does not work, I just want a:
if (version > 3.1.3) { }
How can I achieve this?
As a variation of yasimturks solution, I defined one function and a few enum values instead of five macros. I find it more elegant, but that's a matter of taste.
Usage:
.h file:
.m file:
You should add your app's prefix to the names, especially to the
Comparison
type.Just for retrieving the OS version string value:
Starting Xcode 9, in Objective-C:
Starting Xcode 7, in Swift:
For the version, you can specify the MAJOR, the MINOR or the PATCH (see http://semver.org/ for definitions). Examples:
iOS 11
andiOS 11.0
are the same minimal versioniOS 10
,iOS 10.3
,iOS 10.3.1
are different minimal versionsYou can input values for any of those systems:
iOS
,macOS
,watchOS
,tvOS
Real case example taken from one of my pods:
documentation
I always keep those in my Constants.h file:
This is used to check for compatible SDK version in Xcode, this is if you have a large team with different versions of Xcode or multiple projects supporting different SDKs that share the same code:
What you really want is to check the iOS version on the device. You can do that with this:
Swift version:
Current versions of swift should be using this: