I'm trying to migrate over to the Swift 6 language mode, but the biggest issue I'm facing is that any use of SwiftData #Predicate or SortDescriptor results in this warning from the compiler:
Type 'ReferenceWritableKeyPath<GuruSchemaV2.Rubric, Bool>' does not conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode
Here is an example predicate, from a static method on the Rubric type:
static func notArchived() -> Predicate<Rubric> {
return #Predicate<Rubric> { rubric in
!rubric.archived
}
}
And the error highlights line 5 of the expanded macro:
Foundation.Predicate<Rubric>({ rubric in
PredicateExpressions.build_Negation(
PredicateExpressions.build_KeyPath(
root: PredicateExpressions.build_Arg(rubric),
keyPath: \.archived // <- Warning here
)
)
})
What is the correct way to reference properties of a model type using #Predicate?
Edit: Rubric is a large class but here is the declaration and relevant properties:
@Model
class Rubric: Identifiable, Comparable {
init() { ... }
var subject: String = ""
var unit: String = ""
var archived: Bool = false
// ...
}

ReferenceWritableKeyPathdoes not conform toSendable. @Sweeper you can copy & paste the code into a new project and correct as needed (remove Identifiable, Comparable, and the filler ellipses).