[swift-evolution] Idea: Support #if os(Darwin) as shorthand for os(iOS) || os(OSX) || os(watchOS) || os(tvOS)

Colin Cornaby colin.cornaby at mac.com
Sat Feb 20 13:35:18 CST 2016

I’ve mentioned this before, but often checking for simulator is really a just a way of dealing with an include that won’t work in the simulator. The ability to exclude code based on the presence of a module in the SDK would be most welcome. Metal is my current sticky point with Swift. It’s in the device SDK but not the sim.

> On Feb 19, 2016, at 8:01 PM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
>> • Is the target an Apple platform (iOS, OS X, tvOS, watchOS) or not? (Answers the question "can I import Foundation"?)
> Well, Corelibs Foundation will muddy those waters.
>> • Is the target a "common UIKit platform" (compiles on both iOS and tvOS) or not? (Answers the question "can I import UIKit"?)
> Maybe test for the presence of a particular module?
> 	#if supports(Foundation)
> 	#if supports(UIKit)
> Or allow conditional importing of a module?
> 	#if import UIKit
> 		// Only compiled if UIKit imported; all UIKit APIs usable here
> 	#elseif import AppKit
> 		// Only compiled if AppKit imported; all AppKit APIs usable here
> 	#endif
> 	// No AppKit or UIKit APIs usable here
> -- 
> Brent Royal-Gordon
> Architechies
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list