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

Dany St-Amant dsa.mls at icloud.com
Wed Mar 23 20:27:57 CDT 2016

> Le 22 mars 2016 à 18:14, Erica Sadun via swift-evolution <swift-evolution at swift.org> a écrit :
>  <https://gist.github.com/erica/b7f4226b8201945602f2#motivation>Motivation
> Swift's existing set of build configurations specify platform differences, not module commonalities. For example, UIKit enables you to write view code supported on both iOS and tvOS. SpriteKit allows common code to render on OS X, iOS, and tvOS that would require an alternate UI on Linux. Testing for Metal support or Media Player would guard code that will not function on the simulator. If the simulator adopted these modules at some future time, the code would naturally expand to provide compatible execution without source modification.
> #if canImport(UIKit)
>    // UIKit-based code
>    #elseif canImport(Cocoa)
>    // OSX code
>    #elseif
>    // Workaround/text, whatever
> #endif
Not sure if its because I mainly live in a world of multi-architectures C cross-compiling, but for example if you canInclude some powerpc header, it does’t mean that your are compiling for powerpc. So, IMO, I think that #if didImport(Cocoa) would be a better wording. This effectively prevent one from doing:

#if didImport(Cocoa)
  import Cocoa // Pointless, won’t work

So for conditionally import, we would still be forced to use some form of #if os(OSX)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160323/41dda4f0/attachment-0001.html>

More information about the swift-evolution mailing list