Towards a Design System in iOS: Colors

Jun 2 · 4 min read

An important aspect to the success of an application is how it looks, and how easy it is to use. These two aspects are what we call UI/UX, and they are not easy to get right, even though, fortunately, the iOS frameworks already give us a very good result with default components.

Consistency is key to achieve a good UI/UX in an app. From a user’s perspective, it is paramount that things that are the same, look the same, and are used the same. This helps them relate knowledge from previous features in your app, or in the system, and quickly learn how to use new functionality. But that does not stop there; from a developer’s perspective, it also has great benefits, as existing components and interactions can be easily reused.

As part of our efforts to enhance consistency across GoodNotes, our team has been working on a Design System: a library of tokens and components that we can refer to when implementing new features into the app. It serves as a common language between designers and developers to unambiguously refer to certain items in our software and improve the way we work.

We are still in the process of adopting it, but we found some interesting aspects that we would like to share with you. In this first post, we will focus on colors.

Colors in iOS

In our project, we try to use named colors defined in our Assets in Xcode. This lets us define semantic colors that include variants for light and dark modes, and get the right one without too much hassle.

This also lets us have a visual representation of all colors in the application, and verify that they are correct in both themes. These colors are available through the Interface Builder, or we can instantiate them using the UIColor(named:) initializer.

There is a small problem though: our designers usually work in Figma, not in Xcode. We need a way to import their list of colors into our project. Moreover, when they change something, we don’t want to go over the list of colors and manually update them in our Assets.

There are tools to automate the generation of colors from Figma, like Style Dictionary, and it not only works for iOS, but for other platforms, which may become useful in the future. However, if you take a look at the generated output, it has two main shortcomings:

  1. It does not use named colors in Assets.

Tweaking Style Dictionary

Fortunately, Style Dictionary is customizable through plugins, so we wrote one to let us customize the output to match our needs. The task became surprisingly easy thanks to using Handlebars, a template system that can render our data in the format we would like.

First, we created a template for named colors that allows us to put together both light and dark versions of a color. It took us a bit of reverse engineering how Xcode represents colors in the colorset folders.

The template looks like:

Handlebars template to generate color assets

Most of the template corresponds to the JSON format that Xcode uses to represent named colors, but the values enclosed by double curly braces ({{ }}) are the gaps that we can fill with light and dark variants of our color. We run this template for each color our designers define in Figma.

Finally, in order to have a convenient way of using these colors programaticaly, we generate a custom UIColor extension with values for the generated colors:

Handlebars template to generate UIColors

This way, whenever our designers refer to the color GoodNotesDenim600, with variants for light and dark mode, we only need to call UIColor.goodNotesDenim600, and the system will handle variants for us. If, for some reason, our designers decide to add new colors, or update existing ones, we only need to generate them again.

In case we transitioned to use SwiftUI (or you are already using it), our template to generate colors wouldn’t change much:

Handlebars template to generate SwiftUI Colors

Similar to its UIKit counterpart, this offers a good API to work with colors in SwiftUI. The Assets catalog is shared, so we can even have both versions (UIColor and SwiftUI.Color) coexisting in the same code base.


Style Dictionary is a very useful tool to translate resources provided by designers using Figma, into resources that can be targeted to different platforms, like iOS in our case. However, it has some shortcomings when it comes to dealing with named resources, and light and dark modes. Thanks to its powerful extension capabilities, we can customize the generation process to fulfill our needs and unlock additional benefits, like nicer APIs to work with colors.

Did you like what we are doing? Do you want to join us, and help us shape up the future of GoodNotes? We are hiring!

This article was written by:
Tomás Ruiz-López is a Senior Software Engineer working in the iOS team at GoodNotes. He enjoys learning new technologies in the Apple ecosystem and looking at them from the prism of Functional Programming. He has developed several open source projects related to the Bow library, an attempt to bring FP concepts into Swift.

Engineering At GoodNotes

How we’re creating the best digital paper

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store