Colorizer
Colorizer copied to clipboard
This project is no longer maintained
Please check Named Colors (available from Xcode 9). It's possible to use it with SwiftGen.
Colorizer
Colorizer is a tool written in Swift to auto-generate a Apple's Color Palette file (.clr file) from .txt file.
In result you can:
- use the same colors in code and storyboards
- share project colors
- be sure that you are always up to date
Installation
-
Via CocoaPods
Simply a
pod 'Colorizer'to yourPodfile.Now you can use Colorizer in Build Phases invoking
$PODS_ROOT/Colorizer/bin/colorizer. -
Via Homebrew
You can install Colorizer just by:
brew install arturjaworski/formulae/colorizer
Usage
colorizer generate /path/to/colors-file.txt /path/to/output-color-palette-file.clr
This will generate a Apple's Color Palette file with all colors listed in the text file passed as argument.
Your input text file should be contain one color per line, each line being composed by the Name to give to the color, followed by :, followed by the Hex representation of the color (like rrggbb or rrggbbaa, optionally prefixed by # or 0x). Whitespaces are ignored. Almost the same as used in SwiftGen.
It means it's looks like:
Black : #000000
White : ffffff
Translucent : 0x111111cc
Title : #ff0000
Tips & Tricks
-
Generate Swift code from the same
.txtfile bySwiftGen. -
Share your
.txtfiles in your project directory. -
Integrate Colorizer with your Xcode project to regenerate
.clrfile on every build using Build Phases. -
Install your color palette in your system placing it in
~/Library/Colors/.
Also you can add it as "Run Script Phase": ln -sf ${SRCROOT}/color-palette.clr ${HOME}/Library/Colors/${PRODUCT_MODULE_NAME}.clr
License
This code and tool is under the MIT License. See LICENSE file in this repository.
It also relies on SwiftCLI and PathKit licenses.
Any ideas and contributions are welcome!