Code integration just could not be
more natural and seamless

The main purpose of Colors Coder as a developer tool is to generate Swift code from collections and colors, so Swift developers can minimize, even eliminate, the need to create custom color managers for managing colors in their apps. And that is something that ultimately leads to less programming hours and effort.

But in order for Colors Coder to be really useful and successful, it should not require from developers to learn how to use the generated code, it should not introduce any new API, and it should not set any limitations to development process or developer's habits.

And indeed, generated code is far from all these, as it integrates perfectly to any project, and using it feels as natural as accessing any other property of the UIColor or NSColor class.

Using Colors Coder generated code

It really couldn't be simpler than that:

Access any exported collection you want as a UIColor or NSColor class property, and the desired color as a property of the collection.

For example, here is how to set the Lava color of the Colorful collection as the background color of the customView, a UIView object:

customView.backgroundColor = UIColor.Colorful.Lava

Moreover, what is really great is that you don't have to remember any names, as Xcode will auto-suggest them for you!

Switching among color themes using the Default collection

Often, you will want to support various color themes in your apps, such as light & dark modes, and switching among them is where things start getting complicated. However, that is not a problem when using generated code by Colors Coder, as it makes the theme changing process just a matter of calling a method.

First things first though!

When code is generated, an additional collection named defaultCollection is included too. It's purpose is to act as a general solution that enables you to avoid reference to specific collection names, and therefore to make it possible to use various collections as themes in your apps.

Using the default collection is similar to accessing any other collection, with the only difference being that instead of using a specific collection name, you use the defaultCollection:

customView.backgroundColor = UIColor.defaultCollection.background

When code is generated, the first collection found in your Colors Coder document is assigned as the default one. However, setting another collection as the default one can be done by calling the...

setDefault(colorCollection:) class method of UIColor or NSColor class.

For example, let's say we have three collections named Colorful, Day and Night, with the Colorful being the default one. To switch to Day, and therefore start using colors from that collection, you have to do this:

UIColor.setDefault(colorCollection: .Day)

To change to Night:

UIColor.setDefault(colorCollection: .Night)

* setDefault(colorCollection:) parameters are values of a custom enum which is included in the generated code, called ColorsCoderCollection.

To recap in one sentence only:

Switch among color collections (themes) by calling the setDefault(colorCollection:) method, and access your colors using the defaultCollection collection.

Well documented generated code

Generated code by Colors Coder is well documented, and it even contains usage examples based on the color collections exported as code. All colors have detailed description about their values, profile, name, etc. There's even a color sample on each color description which if uncommented or copied, it shows the actual color in Xcode editor.