Core Data Derived Attributes with a sum function: unsupported. Crash at launch

I have two entities in my app: User & Expense. A user has many expenses. Expense as an attribute amount (of type Int32).

I added a derived attribute expensesCount (of type Int16) on the user to count the number of expenses, using the derivation expenses.@count. It's working fine, the app compiles, launches, and when I save a relationship, the value for the expensesCount attribute is updated.

I also added a derived attribute expensesAmount on the user to count the total amount of all related expenses. I use the derivation expenses.amount.@sum. The app compiles but crash at launch with the following error:

Code Block
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'currently unsupported (unsupported function on to many (not count or sum))'

Any idea why?

PS: I also tried another synthax recommended on Twitter (by Scott Perry from Apple team): sum:(expenses.amount), but I got the same crash.

From my understanding, it's only possible to use the @sum function for one to many relationships, and not many to many. In my project, the derived attribute is using a many to many relationship (one user can have many expenses, and an expense can have many users). I opened a feedback FB8889366 // https://feedbackassistant.apple.com/feedback/8889366
Core Data Derived Attributes with a sum function: unsupported. Crash at launch
 
 
Q