Swift’s new #Predicate macro turns query filtering into a type-safe, compile-time-checked process for SwiftData, but it requires comparing scalar identifiers—not whole objects—to generate valid database expressions. This guide explains how it works, why object comparisons fail, and the correct pattern for writing robust SwiftData filters.
