Detecting available API iOS vs. watchOS in Swift
In the Apple dev guide, it is said that the star, *
(which is required) means that it will execute the if
body for OSes not specified but listed in the minimum deployment target specified by your target.
So, if your target specifies iOS and watchOS, your statement if #available(iOS 9.0, *)
means that the if
body is available for iOS 9 and later and any watchOS version.
Also, be careful if you want to use what's described in the chapter "Build Configurations" in this Apple guide. It is used to conditionally compile your code based on the operating system. This is not dynamic at runtime.