Search code examples
iosswiftxcodeios11ios12

Why does #available(iOS 11, *) resolve to true on iOS 12?


My understanding of the #available syntax was that it was specifying the major / minor versions of iOS. However, I am noticing that code protected by this if clause will be executed on iOS 12.

Is it expected that #available resolves to a >= check?

It appears to do this whether it has been compiled by the current version of Xcode (targeting iOS 11) as well as the beta version targeting iOS


Solution

  • Yes, that is expected. #available is meant to be used to enclose functions that have been added in specific iOS version, that are available since that version forward.