CIColor.init(color: UIColor) not working properly on macOS 14 Catalyst

When initializing a CIColor with a dynamic UIColor (like the system colors that resolve differently based on light/dark mode) on macOS 14 (Mac Catalyst), the resulting CIColor is invalid/uninitialized. For instance:

po CIColor(color: UIColor.systemGray2)
→ <uninitialized>
po CIColor(color: UIColor.systemGray2.resolvedColor(with: .current))
→ <CIColor 0x60000339afd0 (0.388235 0.388235 0.4 1) ExtendedSRGB>

But also, not all colors work even when resolved:

po CIColor(color: UIColor.systemGray.resolvedColor(with: .current))
→ <uninitialized>

I think this is caused by the color space of the resulting UIColor:

po UIColor.systemGray.resolvedColor(with: .current)
→ kCGColorSpaceModelRGB 0.596078 0.596078 0.615686 1 
po UIColor.systemGray2.resolvedColor(with: .current)
→ UIExtendedSRGBColorSpace 0.388235 0.388235 0.4 1

This worked correctly before in macOS 13.

FB12914857. Thanks for looking into this!

Its unclear what is going wrong here, as the implementation is just return [self initWithCGColor:color.CGColor] – but doing that directly doesn't encounter the same issue

So thats the workaround, use -[CIColor initWithCGColor:] instead.

CIColor.init(color: UIColor) not working properly on macOS 14 Catalyst
 
 
Q