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

I get this red warning in Xcode every time my app is syncing to the iCloud. My model has only basic types and enum that conform to Codable so i'm not sure what is the problem.

App is working well, synchronization works. But the warning doesn't look good.

Maybe someone has idea how to debug it.

Answered by guciox in 819384022

I was able to fix the problem by removing enum from my model. I had this enum:

var goalType: GoalType = GoalType.regular

enum GoalType: Codable {
    case regular
    case auxiliary
    case special
}

I made migration and deleted this entity from my model and the error stopped appearing.

The error message indicates that something in your project uses NSKeyedUnarchiveFromData to un-archive data, which is deprecated because it is insecure, and can be replaced with NSSecureUnarchiveFromData. It can be your code, or a 3rd-party or system framework you project uses.

If you've confirmed that it is not your code or any 3rd-party framework you introduced, I’d suggest that you file a feedback report with a minimal project that reproduces the issue for the framework engineer to investigate – If you do so, please share your report ID here.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Accepted Answer

I was able to fix the problem by removing enum from my model. I had this enum:

var goalType: GoalType = GoalType.regular

enum GoalType: Codable {
    case regular
    case auxiliary
    case special
}

I made migration and deleted this entity from my model and the error stopped appearing.

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