JSON design tokens to Swift colors. Zero configuration required. with Claude Code
- Auto-discovers colors from JSON files
- Light/Dark mode with automatic switching
- Multiple access patterns (property, subscript, namespace)
- Fallback system for missing colors
- SwiftUI and UIKit support
- Figma token compatible
dependencies: [
.package(url: "https://github.com/ParkSY0919/ColorKit.git", from: "0.2.0")
]- File → Add Package Dependencies
- Enter
https://github.com/ParkSY0919/ColorKit.git - Assign both ColorKit and ColorKitPlugin to your target
1. Add JSON file to your project
Create colors.json and add it to your Xcode project:
- Drag the file into Xcode
- Check "Copy items if needed"
- Check your app target in "Add to targets"
{
"brand-primary": "#007AFF",
"background-main": "#FFFFFF",
"text-heading": "#1D1D1F"
}2. Configure at app launch
Pass the file name (without .json extension) to configure():
import ColorKit
@main
struct MyApp: App {
init() {
ColorKit.configure(jsonFileName: "colors") // loads colors.json
}
var body: some Scene {
WindowGroup { ContentView() }
}
}3. Use colors
Text("Hello")
.foregroundColor(Colors.textHeading.color)
.background(Colors.backgroundMain.color)Create separate files with -light and -dark suffixes:
colors-light.json
colors-dark.json
Colors switch automatically based on system appearance.
// Property access (recommended)
Colors.brandPrimary.color
// Subscript for exact keys
Colors["brand-primary"]?.color ?? .blue
// Namespace access
Colors.Brand.primary.color
Colors.Background.main.color- Detailed Guide - API reference, configuration options
- Demo App Guide - Running and exploring the demo
- iOS 14.0+ / macOS 11.0+
- Swift 5.9+
- Xcode 15.0+
MIT License. See LICENSE for details.