I know Swift is relatively new, but I was wondering if there was a way to determine the device type?
(Like you used to be able to do with a #define
)?
Since Swift 4.2 you can replace
#if os(iOS) || os(watchOS) || os(tvOS)
let color = UIColor.redColor()
#elseif os(OSX)
let color = NSColor.redColor()
#else
println("OMG, it's that mythical new Apple product!!!")
#endif
By
#if canImport(UIKit)
let color = UIColor.redColor()
#elseif os(OSX)
let color = NSColor.redColor()
#else
#error("OMG, it's that mythical new Apple product!!!")
#endif