@State is not Sendable?

This:

struct Content: Sendable {
    @State private var x = "xxx"
}

displays the following warning:
Stored property '_x' of 'Sendable'-conforming struct 'Content' has non-sendable type 'State<String>'

However, State conforms to Sendable. At least according to Xcode documentation. Is this a bug? Any other explanation?

Tested on Xcode 15.0 RC, Strict Concurrency Checking: Complete

1 Like

State does not conform to Sendable.

Actually this is weird; in the Swift Playgrounds documentation it says State does not conform, but in the online documentation it says that it does conform. But seeing as how you're getting this error I assume it does not actually conform to Sendable.

Yes, that is very logical conclusion, and also something I was afraid of. So @State is thread-safe, however not Sendable. Not great, not terrible.