[swift-evolution] [Draft] Adding a Build Configuration Import Test

Brent Royal-Gordon brent at architechies.com
Tue Mar 22 23:24:25 CDT 2016

> #if canImport(UIKit)
>    // UIKit-based code
>    #elseif canImport(Cocoa)
>    // OSX code
>    #elseif
>    // Workaround/text, whatever
> #endif

My question is simple: Are there cases where you want to test if you can import something, but you don't want to *actually* import it? If not, should we perhaps just do this?

	#if import UIKit
		// UIKit-based code, has UIKit available
	#elseif import Cocoa
		// OS X code, has Cocoa available
		// Fallback

Brent Royal-Gordon

More information about the swift-evolution mailing list