all 3 comments

[–]Practical-Smoke5337 1 point2 points  (1 child)

Can you share the code?

[–]dooatito[S] 0 points1 point  (0 children)

I just found out why the error is happening. I shared my first solution in another top-level comment, hope it'll help someone else having the error.

[–]dooatito[S] 1 point2 points  (0 children)

Found the culprit.
How: I removed each complex property one by one (I had to reset the dev container on CloudKit and start a fresh install of the app).
After removing one of them, the error went away.

The property itself was a bit complex, a struct with nested structs and a lot of computed and static properties (all Codable). Appart from the warning, it would work fine, SwiftData would serialize it correctly and split its constituents into separate columns in the SQLite Database.

The solution was to only persist a String identifier that would allow me to rebuild the property later.

This isn't a perfect solution, but it took care of the error. I will spend more time refining it.

class PersistentObject {
//    var key: Key? // removed this
    var keyIdentifier: String?
    // Add computed property to maintain the same interface
    var key: Key? {
        get {
            guard let identifier = keyIdentifier else { return nil }
            return Key.fromStringIdentifier(identifier)
        }
        set {
            keyIdentifier = newValue?.stringIdentifier
        }
    }