#available is unable to detect API availability between WatchOS 2 and iOS
| Originator: | me | ||
| Number: | rdar://22529125 | Date Originated: | 01/09/2015 |
| Status: | Open | Resolved: | |
| Product: | Swift | Product Version: | Xcode Version 7.0 beta 6 (7A192o) |
| Classification: | Important | Reproducible: |
Summary:
Consider the following scenario of code shared between iOS and WatchOS:
lazy var session: WCSession = {
let session = WCSession.defaultSession()
session.delegate = self
return session
}()
...
if #available(iOS 9.0, *) {
guard session.paired else { throw WatchBridgeError.NotPaired } // Error: paired is not available
guard session.watchAppInstalled else { throw WatchBridgeError.NoWatchApp } // Error: watchAppInstalled is not available
}
guard session.reachable else { throw WatchBridgeError.NoConnection }
Steps to Reproduce:
Try to use #available in code shared by a WatchOS 2 and iOS target with API that is annotated with __WATCHOS_UNAVAILABLE on WatchOS 2 and iOS.
Expected Results:
No Compiler errors
Actual Results:
Compiler complains with unavailable API usage even though code if wrapped in appropriate #available
Version:
Xcode Version 7.0 beta 6 (7A192o)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!