Stopping SetNSColor(CGContext*, void const*) Crashes in UIKit
TL;DR I recently encountered a crash on SetNSColor(CGContext*, void const*) with [__SwiftValue CGColor]: unrecognized selector sent to instance. It took a while to find the root cause as the stack trace lacked a lot of detail. Ultimately it was a SwiftUI Color in a UIKit API that expects a UIColor (or raw CGColor). In this case I passed a SwiftUI Color via the .foregroundColor attribute of an NSAttributedString that UIKit then rendered. ...