SwiftData project segfaults when I enabled iCloud sync

The crash is at

        do {
            retval = try ModelContainer(for: schema, configurations: [modelConfiguration])
        } catch {
            fatalError("Could not create ModelContainer: \(error)")
        }

When I first set it up, it complained (at run-time) about a lot of issues, mainly items not being optional and I apparently had a couple of @Attribute(.unique)s left. After I got rid of all of those, however, I get the crash there.

I assume this is an obvious thing that I am doing wrong, but I can't figure it out.

Are you using the default iCloud container or did you define one yourself? I don't see your ModelConfiguration init. Something like the folliowing.

let modelConfig = ModelConfiguration(schema: schema,  cloudKitDatabase: .private("iCloud.com.mycompany.name"))
do {
    container = try ModelContainer(for: schema, configurations: [modelConfig])
 }
catch {
    fatalError("Could not create ModelContainer: \(error)")
 }

I wasn't, but I changed it to match what was in the entitlements file, and it still segfaults the same way at the same place.

I eventually tracked this down: one of my @Models had a (Codable) enum in it. I removed that, and it didn't crash. (I may have had to also reset everything programmatically? I forget.)

SwiftData project segfaults when I enabled iCloud sync
 
 
Q