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

Brent Royal-Gordon brent at architechies.com
Wed Mar 23 02:21:22 CDT 2016

> My guess is most often one will want to import exactly what one is testing (Brent example) but I guess it would be very handy to do something like
> #if canImport(Foo)
>    import Foo.Bar as FooBar
> #endif

I don't see any particular reason you couldn't support anything `import` can support in an `#if import`.

> Also +1 on Haraviks point:
>> My only question is whether there should be a way to test minimum module versions? If I add support for a module but target a particularly recent version then that support won’t compile for platforms with older versions of the same module, so I should be able to prevent them from being a match.

I think we'd be better off extending our existing `@available` and `#availability` mechanisms to test module versions in addition to platform versions. Two small, orthogonal features are better than one big, confused one.

Brent Royal-Gordon

More information about the swift-evolution mailing list