I have a model in Swift that looks like:
import Foundation
import SwiftUI
struct Note: Hashable, Codable {
var title: String
var createdDate: Date
var notes: String
var color: Color
var niceDate: String {
let dateformatter = DateFormatter()
dateformatter.dateStyle = .medium
return dateformatter.string(from: self.createdDate)
}
}
Now, it can't conform to codable because Color doesn't conform. However, I cannot extend it otherwise it gives me the error Implementation of 'Encodable' cannot be automatically synthesized in an extension in a different file to the type
How can I make Note (with the color attribute) conform to Codable? Ideally it could be applied to other builtin types as well.