To get the current devices (or simulators) iOS version you can use the following code:
var systemVersion = UIDevice.current.systemVersion
print(systemVersion)
// 13.3
If you want to only run code if it meets a certain iOS version, you can use the #available
syntax.
if #available(iOS 13.0, *) {
// use iOS 13 feature
} else {
// use workaround
}
Instead of checking the iOS version, you can check if it respondsToSelector
. This allows you to check specific methods, not relying on the iOS version.
if (self.respondsToSelector(Selector("showViewController"))) {
self.showViewController(vc, sender: self)
} else {
// alternative solution
}
The Complete iOS App Development Bootcamp
Disclosure: This website may contain affiliate links, meaning when you click the links and make a purchase, we receive a commission.