2

I have a project that will not compile, after upgrading to Xcode 13.3 The error is

Type 'CircularBuffer<Element>' does not conform to protocol 'MutableCollection'

and

Unavailable subscript 'subscript(_:)' was used to satisfy a requirement of protocol 'MutableCollection'

This is in the public struct MarkedCircularBuffer<Element>: CustomStringConvertible that is part of SwiftNIO.

This pops up as soon as I try to build the project, which built and ran fine prior to the upgrade to Xcode 13.3.

I don't have a starting point to figure this out. What should I be looking for? My only intuition is that a number of async queries in my code dump the result into a _ rather than a variable, but that seems reasonable given the compiler suggests it…

EDIT: because there is a reference to protocols, I checked my code, and only one protocol is defined (but never implemented):

protocol storesSockets {
//    var sockets: Dictionary<String, Dictionary<String, WebSocket>>
    func addSocket(ws: WebSocket, pId: String, gameId: String, overwrite: Bool)
}

Commenting this code out does not change anything.

UPDATE: I tried updating the packages in Swift... this caused a crash, which restarting Swift didn't fix, but restarting the machine did. Or seems to have. So my problem has gone away...

Dan Donaldson
  • 1,061
  • 1
  • 8
  • 21
  • That sounds like a compiler bug that can probably be worked around by updating the Vapor & SwiftNIO package versions. – Johannes Weiss Apr 03 '22 at 07:32
  • What versions of SwiftNIO & Vapor are you using? And did you try `swift package update` on the command line or “Update to latest Package Versions” in Xcode? – Johannes Weiss Apr 03 '22 at 07:33
  • There may be a bug in SwiftNIO in that the subscript method should have ´override´ . – Ptit Xav Apr 03 '22 at 08:32
  • thanks for the feedback... I was trying to get things running without updating the packages, just nervous about having to deploy and upgrade the server as well. But I also needed to keep moving. So Johannes' suggestions are what happened. – Dan Donaldson Apr 04 '22 at 07:38
  • @PtitXav `override` is only for sub-classes. There are no sub-classes here. Swift is souce-stable since 3.0.0 so anything an old Swift compiler compiled should in theory be compileable by a newer one (that’s why Swift has language compatibility versions). – Johannes Weiss Apr 04 '22 at 14:46

1 Answers1

4

I ran into the same problem and updated swift-nio to 2.40.0 to solve the problem.

EDIT: Updating caused a crash sometimes (this might be related to the Apple Silicon M1 Mac) but after the crash and the finished update the error was gone.

SirDeLight
  • 43
  • 1
  • 6