I tried reproducing this but couldn’t.
Having seen the error myself, I could reproduce it as follows:
Paste the three structs from the op's original post into a Swift file in a new app project.
Change "Decodable" for each to "Codable" (I couldn't reproduce it for "Decodable" only for some reason).
Make sure that strict concurrency checking is set to "Complete" and "MainActor" is set as the default actor isolation for the project.
When I do this, I see a "Circular reference" error with several "Through reference here" comments that don't make much sense.
There seem to be two possible fixes depending on how the struct is intended to be used:
Explicitly set the struct as "nonisolated" (which prior to the change in default actor isolation would have been the default):
nonisolated struct FriendListResponse: Codable
Force the conformance to @MainActor:
struct FriendListResponse: @MainActor Codable
(Note that the second solution will break if you use custom codingKeys, however, even if you try to force the conformance on that to @MainActor - not sure why.)
I hasten to add that my knowledge of Swift 6 and concurrency is wanting - I'm only starting to explore migration from Swift 5 to Swift 6 and understanding the errors involved, so apologies to the op if this is unhelpful.
Topic:
Programming Languages
SubTopic:
Swift
Tags: