I've added a light mode color and a dark mode colour and set the color like this.
override func viewDidLoad() {
super.viewDidLoad()
titleLabel.textColor = .CP2
view.wantsLayer = true
view.layer?.backgroundColor = NSColor.myColor.cgColor
}
Regardless of dark mode and light mode, the color is always the Any Appearance color.