How to use SE-0353 features? (Constrained Existential Types)

SE-0353 has supposedly been in main for a long time now. but i can’t figure out how to enable it in SwiftPM. i’ve tried:

swiftSettings: [.unsafeFlags(
["-Xfrontend", "-enable-experimental-bound-generic-extensions", 
"-Xfrontend", "-enable-parametrized-protocol-types"

and the alternative spelling

swiftSettings: [.unsafeFlags(
["-Xfrontend", "-enable-experimental-bound-generic-extensions", 
"-Xfrontend", "-enable-parameterized-protocol-types"
1 Like

Similar question here.

Constrained existential types are enabled by default now on main, so the enable-parameterized-protocol-types option doesn't exist anymore.


Sure, but it's still not usable om MacOS 12.4, Xcode 13.4.1 with both the 5.7 toolchain from 14 June and the main toolchain from 17 June.

As in the link I mentioned above I too get the build error:
"runtime support for parameterized protocol types is only available in macOS 99.99.0 or newer"

Maybe this requires a MacOS 12.5 beta?

It is iOS 16+:

It is worth noting that this feature requires revisions to the Swift runtime and ABI that are not backwards-compatible nor backwards-deployable to existing OS releases.

Note that you can use constrained existentials in limited ways on older deployment targets, and those ways are powerful enough that you can almost get to feature parity, just in a less convenient way than you can on newer deployment targets. In particular, you can declare parameters, variables, properties, and return values as having a constrained protocol type. So while the restrictions mean you can't have a generic type argument that's a constrained existential type (and therefore you can't write e.g. [Collection<Int>]), you can make a struct which wraps a constrained existential type and then use that struct as a generic type argument (e.g. [MyCollection<Int>]).

The only hard restriction is that you can't cast to these types until you bump your deployment target to iOS 16.