I have several color sets defined in Colors.xcasserts. And those colors are defined by json format. For instance, below is for Gray50 color's json definition.
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.616",
"green" : "0.600",
"red" : "0.584"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
But I'm unable to init it from UIColor, but to use Color in SwiftUI is OK. However, in my circumstance I need to use UIColor. Is this json format color is not support on UIColor, or something I missed?


One reason for this to occur is to add a color asset to the project and then use the po command without rebuilding. The build is not needed for SwiftUI but is for UIKit.
Apparently the SwiftUI and UIKit frameworks are architected differently in this regard. Perhaps this is due to some additional processing needed for SwiftUI's Preview.
The following is my recreation by adding Gray50 to the project without rebuilding:
After rebuilding it is working: