ARTICLE AD BOX
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 // ... }9471 gold badge8 silver badges15 bronze badges
4
