My version of ColorGroups for my Swift Framework

after looking into how Xojo defined ColorGroups, I thought it was overly complex, but I needed a similar function for my Swift Framework… this is what I came up with

In the XML code there would be lines like these (best in the App.Open, method)

ColorGroup("color1",.red,NSColor(RGB:0x123456))
ColorGroup("color2",&c993399,NSColor(RGB:0x123456))
Dim c As Color = color1

the format is “colorName”,lightColor, Darkcolor

once it is translated, the ColorGroup statements create entries in the Assets.xcassets catalog
like this

the remaining line is translated to this

var c : NSColor = NSColor( named : "color_COLOR1")!

the colors will automatically change as the app moves from light to dark etc.

1 Like