R.swift can parse .clr color palette files and generate structs in R.colors.*
.
This is useful if you're using .clr color palettes as the source of colors in your project.
NOTE: Make sure the .clr file is part of the project, and a member of the target, for R.swift to pick it up.
A potential work flow is this:
A designer maintains a color palette called
App Colors.clr
, a developer refers to colors like so:R.colors.appColors.errorColor()
.When the designer updates the color, the new
App Colors.clr
file is copied to the project, and R.swift will generate a new color constant with the same identifier.
There are some things to be aware of to using .clr files in a Xcode project:
.clr
files must be placed in the~/Library/Colors
directory to show up in Mac OSX's color picker. The color picker is used across different applications, for example in Pixelmator and Interface Builder..clr
files are binary, so conflicts between two versions of the same file are not easily resolved.- Colors chosen from a color palette in Interface Builder are copied to the .xib or .storyboard, they're not references. If the color palette changes, the old colors are still used in Interface Builder.
The above points are not resolved by R.swift, so keep these in mind when using color palettes!
- Discussion on using other file formats
- R.swift issue: Add support for R.colors from .clr files
- Natasha The Robot: Xcode Tip: Color palette