I have an SwiftUI app that uses CloudKit. I have model classes and I read and write data to CloudKit. I wanted to convert the app to use SwiftData. Here is a sample model class.
@Model class User {
var firstName: String?
var lastName: String?
var location: CLLocation?
var photo: Image?
}
When I read and write this to CloudKit the variables map like this:
String -> String
CLLocation -> LOCATION
Image -> ASSET
When I try to compile the above class, I get these error for CLLocation and Image.
Instance method 'setValue(forKey:to:)' requires that 'CLLocation' conform to 'PersistentModel'
Instance method 'setValue(forKey:to:)' requires that 'Image' conform to 'PersistentModel'
How can I use variable types such as CLLocation and Image with SwiftData?