Wrap availability check in compilation condition

Currently we can't do availability check conditionally:

// use Apple's Combine
@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) // Error: Expected expression
// use open-source Combine
struct MyPublisher: Publisher {}

It's also useful to enable property wrapper conditionally:

struct A {
    #if ENABLE_FOO
    var a: Int

Can we lift this restriction?


Sounds like a good idea to me! I think it should definitely apply to all attributes though, not just @available.

Terms of Service

Privacy Policy

Cookie Policy