Search code examples
swiftios11

How to detect iOS11 programmatically in Swift?


I saw in the WWDC video that there's some new swift function to detect iOS 11 availability.

How do I detect iOS11 with Swift?


Solution

  • Swift 3:

    if #available(iOS 11.0, *) {
      // Running iOS 11 OR NEWER
    } else {
      // Earlier version of iOS
    }
    

    More information is available in Declaration Attributes section of Apple's Swift Programming Guide.