TIL about this "CustomAvailability" experimental feature in Swift. Looks like Apple is using it for feature flags 👀
@_inside There’s a pitch up on the forums at https://forums.swift.org/t/pitch-extensible-availability-checking/79308. The feature seems very appealing to help manage feature flags as well as separately-versioned libraries, but there’s still details to sort out.
[Pitch] Extensible availability checking

Swift gives developers a way to limit the use of declarations in certain contexts using the @available attribute. For example, a library developer can specify that a new API is only available at runtime on macOS 15 or newer using @available: @available(macOS, introduced: 15) public struct Foo { /* ... */ } The compiler only accepts references to the struct Foo in code that proves that it executes on macOS 15 or later, using either @available or if #available(...): let _ = Foo() // error: 'Foo...

Swift Forums