Persisting Color from ColorPicker

Has anyone successfully persisted Color, particularly in SwiftData? So far my attempts have failed:

  1. Making Color conform to Codable results in a run time error (from memory something about ColorBox).
  2. Color.Resolved already conforms Codable but this results in "SwiftData/ModelCoders.swift:124: Fatal error: Composite Coder only supports Keyed Container"

None of the other color types conform to Codable (CGColor, NSColor and UIColor) so does the swift language really not have a persistable color type?

You could create a class that has the component elements of the color as properties and have convenience propertie(s) that return a color using the stored properties.

Save it as a String and add the Hex color #

Persisting Color from ColorPicker
 
 
Q