[swift-evolution] [Draft] Adding a Build Configuration Import Test
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 :
> 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
> // Workaround/text, whatever
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:
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...
More information about the swift-evolution