Avatar ·

How to check the version of iOS/macOS operating system in Swift?

Hi everyone! I'm new to Swift and writing an app for iOS and macOS. I need some features to work only on specific OS versions. For example, I want to use `UIScene` on iOS 13+, but I don't want the app to crash on older devices. The problem is that I don't know how to properly check the system version. First, I tried something like this: ``` if UIDevice.current.systemVersion >= "13.0" { // code for iOS 13+ } ``` But it didn't work — the compiler complains about comparing strings. Then I found a version with `ProcessInfo` on the internet, but it seems too complicated: ``` let osVersion = ProcessInfo.processInfo.operatingSystemVersion if osVersion.majorVersion >= 13 { // ... } ``` It works, but I don't like that I have to split the version into pa