Xcode 16 beta 3
Assume a SwiftData model starts like this and has a few more properties like a name and creation date (these are immaterial to my main question.
@Model
final class Batch: Identifiable, Sendable {
@Attribute(.unique) var id: UUID
//... more stuff
The combination of Swift 6 (or Swift 5 with warnings enabled) and SwiftData seem to provide a paradox:
Swift 6 complains when the id is a let:
Cannot expand accessors on variable declared with 'let'; this is an error in the Swift 6 language mode
Swift 6 complains when the id is a var:
Stored property '_id' of 'Sendable'-conforming class 'Batch' is mutable; this is an error in the Swift 6 language mode
Removing "Sendable" may be one solution but defeats the purpose and causes warnings elsewhere in the app about the model not being Sendable.
Is there an obvious fix?
Am I as a newbie (to the combination of Swift 6 and SwiftData) missing an entire architectural step of using ModelActor somewhere?
1
1
4.1k