I'm also getting this crash as well on iOS18 simulators in Xcode 16 b4 but not on iOS17 simulators, it looks related to deleting a object from within a context menu I've opened up a feedback with the attached project FB14672741
Post
Replies
Boosts
Views
Activity
Here is an image of the crash I'm getting on app launch. A few things I've tried with no luck:
Removing Migration Plan, this has no effect and the issue is still there
Removing the model container when setting up the app, has no effect and the issue is still there
I'm convinced this is linked to using non-default types like Date with transformable. Since I've tested out a project where I have a Date as a transformable property, this doesn't crash. But if I use something from UIKit or my own custom type it crashes.
I am facing the same issue, this was working perfectly fine for me in Xcode 15.0.1, I just tested my app using Xcode 15.2 Beta and I'm getting Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) on the same line where I try to create a model container ModelContainer(...) looks like a regression to me. I would open a Feedback
Filled a feedback here FB13330752
This seems to be an issue on simulators in Xcode 15+. The app settings location permissions appear on a real device, but not on any of the simulators. I did find a hack to make it appear and this was by requesting ATT permission this does show both the location & ATT permission.
I’ve filled a feedback myself FB13330752
Below is my post with more info describing the issue.
https://developer.apple.com/forums/thread/740598
This still is an issue in Xcode Version 15.1 beta (15C5028h)
Is the ModelActor working for you? I've noticed that no matter what it's always on the main thread. Other developers are seeing this too in Xcode 15 b8 and above.
Feedback filed FB13202320
Ok a bit more info, so it seems that it's more related to the fact that SwiftData doesn't like filtering or sorting on optional values... Below is an example of me filtering based on a non optional string and the fetch request works
let fetch = FetchDescriptor<Item>(predicate: #Predicate { $0.title == "G" })
let results = try? modelContext.fetch(fetch)
print("Found \(results?.count) items") <--- This returns results that match the query
When trying to filter and sort on optional properties like an enum or my property category this is where the issue arises... It seems to crash when trying to access the rawValue and also you get no results when you try to filter based on the case. Below is an example of be executing a query on an optional enum.
let high: Priority = Priority.high
let fetch = FetchDescriptor<Item>(predicate: #Predicate { $0.priority == high })
let results = try? modelContext.fetch(fetch)
print("Found \(results?.count) items") <--- Returns nothing & accessing the raw value crashes...
I hope someone on the Apple team sees this since it seems SwiftData and optionals just don't play nicely...
This is on Xcode 15 RC
So they do work when it comes to CRUD opertations. The issues that i’ve found is when you want to filter or sort i’m getting crashes. Also because my model
uses transformable this is also causing a issues to. it’s almost as if the Query macro can’t handle this type.
i’m going to try and see if it crashes using a FetchDescriptor. If it doesnt then that points me in the direction that Query doesn’t play nicely with custom types…
I am getting a similar crash
SwiftData/DataUtilities.swift:1140: Fatal error: Unexpected type for Expansion: Optional<UIColor>
But this is for a transformable property in my model that is a UIColor, it's happening for me in Xcode 15 RC
I am seeing the same behavior too...It doesn't seem to work with enums at all When I compare the enums I get the following in the console
Query encountered an error: SwiftData.SwiftDataError(_error: SwiftData.SwiftDataError._Error.unsupportedPredicate)
When i try to compare the enums using their raw value i get the following crash reffering to a file within the framework
SwiftData/DataUtilities.swift:1140: Fatal error: Unexpected type for Expansion: Optional<UIColor>
The UIColor is reffering to a color that i have as a transformable property
It would be great if this was resolved before the GM release
I've managed to figure it out after like 4 hours... If you're working with migrations and adding in transformable properties make sure they are optional by default...I'm not too sure if this is by design. But after making my transformable properties optional my migrations started to work again.
So i've managed to nail down that the migration is crashing from V3 because I've added a transformable property...It's like it can't find the store after you add a transformable property and crashes. If I make the transformable property @Transient it will clear all of my data and won't crash but it does clear the entire storage like it's a brand new migration.
Here is the entire migrations log attached
Migration Debugging Logs