I have just updated to Xcode 14 RC (14A309), after weeks of peaceful relationships with previous betas, all benefits of primary associated types look like they're gone
// ❌ Cannot specialize protocol type 'Collection'
extension Collection<MyType> { ... }
// ❌ Cannot specialize protocol type 'Sequence'
func foo(_ x: some Sequence<String>) { ... }
For development with the macOS Ventura SDK, continue to use Xcode 14 beta 6.
If you’re developing for macOS, you won’t be able to use some of Swift 5.7’s features with Xcode 14 RC. Since macOS Ventura release is delayed, the macOS SDK bundled with Xcode 14 RC is still macOS 12.5.
Thank you @stevapple, but I do not understand at all.
I've been running this code for several weeks on 12.5 Monterey. Are you telling that those features require a Ventura runtime? And I have been fooled for weeks of work despite the MACOSX_DEPLOYMENT_TARGET set to 10.13 and no error?
I've been running this code for several weeks on 12.5 Monterey.
And on iOS 12.4 as well (simulator), without any problem. I have logically supposed this code didn't rely on OS-level features.
I'm completely lost.
My questions, for anyone in the Swift team who can understand where I talk from (as a library developer):
I want to use primary associated types and define protocols with primary associated types, opaque parameter types (some in parameter position), protocol specialization (eg any Sequence<String>, some Collection<some Foo>)
I can require Swift 5.7+
I must back-deploy to previous operating systems - iOS, macOS, tvOS, watchOS (because the code is not some demo, it's a reliable library with 7+years of faithful presence in the Swift ecosystem, and 400K+ clones/year)
If you want to use features limited to a specific Stdlib runtime, you will need to use #if available/@available and constrain your code to the environment that supports that feature (in this case that would be iOS 16 and etc). Constraining it to a Swift version isn't enough (since that's the compiler version and not Stdlib runtime version).
As I understood it, the only runtime limited features of Swift 5.7 were string processing and runtime casting to specialized existentials. How is the new protocol syntax limited?
Huh, that's now how I understood the limitation of 353. I thought extension Collection<Int> was just sugar for the existing extension Collection where Element == Int. How are those two different?
I don't know if this is the answer, but I'll note that @stevapple didn't say "runtime"; they said "SDK". The standard library is part of the SDK (specifically, its swiftinterface). So if it really is the Swift 5.7 compiler using the macOS 12 SDK, it's using the Swift 5.6 standard library APIs.
Ah, you're exactly right. It's somewhat surprising it doesn't include the new interface since you can back deploy, but I think that explains what we're seeing @gwendal.roue.