Detecting available API iOS vs. watchOS in Swift
问题 #available does not seem to work when differentiating between watchOS and iOS. Here is an example of code shared between iOS & 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 } // paired is not available guard session.watchAppInstalled else { throw WatchBridgeError.NoWatchApp } // watchAppInstalled is not available } guard