SwiftData Query filter().first crashed in iOS18.2

Hi There,

I have a iOS App which has been published and purely managing data by SwiftData. I use following simple codes everywhere in Views:

... @Query var items: [Item] .... if let firstItem = items.first( where: {...}) { ...

Then I encountered crash at Query that _items.wrapperdValue has some errors.

Then I tried to split first(where...) into ordinary way:

let filteredItems = items.filter(...) if let firstItem = filteredItems.first { ...

It runs OK.

Is it a bug in SwiftData in 18.2 or I missed some steps to facilitate SwiftData macros?

It would help if you provided a more complete code sample. For instance what is in that where condition?

SwiftData Query filter().first crashed in iOS18.2
 
 
Q