SwiftData crash on adding sort argument to Query

Experiencing a crash that is only reproducible on TestFlight or AppStore version of the app, note this does not happen when running from Xcode.

I've isolated the problem to sort argument being added to @Query that fetches a model that sorts based on inherited property.

To reproduce:

@Model class SuperModel { var createdAt: Date = .now }

@available(macOS 26.0, *) @Model class SubModel: SuperModel {

}

@Query(sort: \SubModel.createdAt, animation: .default) private var models: [SubModel]

A similar issue was discussed in this thread. Your case has another layer of complexity - inheritance. Would you mind to have a check if your issue still happens without using inheritance? Also, would you mind to share the OS and SDK version you tested with? Thanks.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

SwiftData crash on adding sort argument to Query
 
 
Q