Hi everyone. I trying to implement some drag and drop functionality together with SwiftData. That requires my model to conform Transferable. And Transferable requires to conform Codable. My code doesn't compile with this error: Type 'Item' does not conform to protocol 'Decodable/Encodable'. The error appears right after I add @Model macro.
Is there a solution or a workaround? Here's my code:
@Model
final class Item: Transferable, Codable {
let createdAt: Date
static var transferRepresentation: some TransferRepresentation {
CodableRepresentation(contentType: .myCustomType)
}
init() {
self.createdAt = .now
}
}
extension UTType {
static let myCustomType = UTType(exportedAs: "com.olexgreen.mytype")
}
Thank you very much