Is it safe to mark SwiftData (@Model) classes as Sendable?

The Sendable documentation says we can mark reference types as Sendable if they "internally manage access to their state."

Adding Sendable conformance to my SwiftData classes silences warnings such as the following: "Non-sendable type '[Item]' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary"

@Model final class Item: Sendable {
  var sampleProperty = ""
}

My understanding is that the compiler would complain if adding explicit Sendable conformance to a swift data model was breaking concurrency rules, but I wanted to check with the community to see what everyone thinks.

Best, Taylor

If possible also add the tag Swift, IMHO it might help to ask in swift.org (https://forums.swift.org/c/swift-users/15) and please cross link this post.

model classes are not internally thread safe, so you should not do this. You can pass the persistentModelID between actors. PersistentIdentifier is sendable.

Is it safe to mark SwiftData (@Model) classes as Sendable?
 
 
Q