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

Erica Sadun erica at ericasadun.com
Mon Mar 28 23:44:38 CDT 2016


On Mar 28, 2016, at 10:37 PM, Jeff Kelley via swift-evolution <swift-evolution at swift.org> wrote:
> 
> This might be crazy, but we could also reuse try here:
> 
> import Foundation
> try import UIKit {
> 	// UIKit Code
> }
> else try import Cocoa
> 	// Cocoa Code
> }
> 
> This would attempt to import UIKit and if it succeeded, run the code in the closure.
> 

The problem with your approach is that the Cocoa code would have to compile under iOS and 
I'm afraid that's a no-go. Build-configuration tests enable entire blocks of code to be removed
from compilation.

-- E



More information about the swift-evolution mailing list