'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release

Hi,

Overview:

  • I get the following error when trying to save / read from SwiftData
  • It happens when I try to save color to SwiftData (code below)

Error

'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release

Questions

  1. How can I resolve the error?
  2. I am not directly using data, I am using just Float values, swift types. Why am I getting this error?
  3. Is there a way to add a breakpoint to stop at the exact type causing the error? (Symbolic breakpoint doesn't seem to help)
  4. Or is the below code ok and not responsible for the error?

Code

import SwiftUI

nonisolated struct ColorRepresentation: Codable {

    let red: Float
    let green: Float
    let blue: Float
    let opacity: Float

    init(colorResolved: Color.Resolved) {
        red = colorResolved.red
        green = colorResolved.green
        blue = colorResolved.blue
        opacity = colorResolved.opacity
    }

    func color() throws -> Color {
        Color(
            red: Double(red),
            green: Double(green),
            blue: Double(blue),
            opacity: Double(opacity)
        )
    }
}

extension ColorRepresentation: Equatable {}

This SwiftData is synced to CloudKit.

Is there any requirement that custom property (struct) needs to implement / conform to any protocol?

Seems find when it is just SwiftData without CloudKit sync, I feel the issue happens only with CloudKit

'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
 
 
Q