Swift 5.7: Runtime parametrized protocols

Hello Swift forum!

I recently started experimenting with new Swift 5.7 features using Xcode 14 Beta. I faced this issue where I'm trying to cast my value into parametrized protocol type, but facing the following error:

Runtime support for parameterized protocol types is only available in iOS 99.0.0 or newer

Full error presented by Xcode:

Is this a normal behavior? Should we, as developers, expect this to be fixed in future Beta releases?

6 Likes

Cc @Arnold

Xcode 14.0 beta3
Runtime support for parameterized protocol types is only available in iOS 16.0.0 or newer
Can it support iOS 13.0?

No, that's why it produced that error.

Any update on this? Are parametrized protocols really limited to only iOS 16+? If so, why?

Runtime casting to a parameterized protocol is limited to the latest OSes because it requires runtime support not otherwise available. You can use parameterized protocols in other ways and still back deploy.

Since the discussion still continues, I feel like I have to state that the problem I originally described in the topic has been resolved since Xcode 14 Beta 2. I wouldn't expect parametrized protocols available on iOS versions below 16.0, unless core team does something similar they did for Swift Structured Concurrency and add backward compatibility for the new Generics features.

You can use parameterized protocols in other ways and still back deploy.

Would you be able to clarify this point or provide resources that do? What scope of SE-0346 is locked behind iOS 16 / macOS 13 compatibility and what is available through back-deployment?

Update:
Per my understanding, SE-0346 is fully backwards-compatible but limited to some existentials, while SE-0353 expands this syntax out to any existentials but requires runtime support and is limited to new OS'.