There’s a nasty main-thread deadlock which occurs in SwiftData when I try to define a custom “id” field for my @Model
object. I’ve created a repository for reproducing the issue, which contains instructions for reproducing the issue + my current thoughts.
My core need here is to be able to fetch data from the server, then replace all of my cached data with the response; server data which exists in the cache should be updated, new server data should be inserted, and cache data which does not exist in the server response should be deleted. I’m struggling to find an elegant solution for this given this deadlocking issue.
https://github.com/philipshen/SwiftDataDeadlockRepro