Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

SwiftData #Predicate in Swift 6 language mode

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
        )
    )
})

What is the correct way to reference properties of a model type using #Predicate?

SwiftData #Predicate in Swift 6 language mode
 
 
Q