{"id":22370359,"url":"https://github.com/dreaminginbinary/colorup","last_synced_at":"2025-06-22T02:34:34.131Z","repository":{"id":41360019,"uuid":"236089654","full_name":"DreamingInBinary/ColorUp","owner":"DreamingInBinary","description":"An easy way to generate strongly typed Swift extensions for either UIColor or Color based off of your colors within the project's asset catalog.","archived":false,"fork":false,"pushed_at":"2021-04-29T18:11:35.000Z","size":60,"stargazers_count":19,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T13:12:09.722Z","etag":null,"topics":["ios","swift","swiftui","uikit","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DreamingInBinary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-24T21:51:53.000Z","updated_at":"2023-09-17T08:13:45.000Z","dependencies_parsed_at":"2022-08-25T08:11:33.815Z","dependency_job_id":null,"html_url":"https://github.com/DreamingInBinary/ColorUp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DreamingInBinary/ColorUp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DreamingInBinary%2FColorUp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DreamingInBinary%2FColorUp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DreamingInBinary%2FColorUp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DreamingInBinary%2FColorUp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DreamingInBinary","download_url":"https://codeload.github.com/DreamingInBinary/ColorUp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DreamingInBinary%2FColorUp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261225506,"owners_count":23127153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","swift","swiftui","uikit","xcode"],"created_at":"2024-12-04T19:45:00.304Z","updated_at":"2025-06-22T02:34:29.117Z","avatar_url":"https://github.com/DreamingInBinary.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"/hero.png?raw=true\" alt=\"Header Image\" /\u003e\n\u003c/p\u003e\n\n### Motivations\nAt [Buffer](https://www.buffer.com) we use color catalogs extensively across our own iOS apps. But, we find that we often can mistype the names (resulting in a nil color instance) and that we have quite a few of them. This is the main problem we set out to solve. Using a generator such as this gives us the flexibility of color catalogs with the advantages of concrete function calls:\n\n```swift\n// Before 😅\n\n// UIKit. If you mess this up or force unwrap, you could crash.\nlet aColor = UIColor(named: \"iHopeITypedThisRight\") \n\n// SwiftUI. If you mess this one up, you'll get primary text by default.\nText(stepToDo.backingModel.stepAbstract ?? \"\")\n                .lineLimit(nil)\n                .foregroundColor(Color(\"gettingStartedTextSubhead\"))\n\n// After. Strongly typed colors, no chance of typos. 😊\n\n// UIKit\nlet aColor = UIColor.namedColor\n\n// SwiftUI\nText(stepToDo.backingModel.stepAbstract ?? \"\")\n                .lineLimit(nil)\n                .foregroundColor(.gettingStartedTextSubhead)\n```\n\nThere are other things in the pipeline for the future, such as supporting Objective-C and bundle asset catalog lookups, but this is our start!\n\n### Usage\nTo install ColorUp, download this repository locally to your machine.\n\nThen navigate to its location:\n```bash\n$ cd location/to/colorup\n```\nFrom there, you must provide two things at a minimum:\n\n1. The fully formed file location of the asset catalog with the colors, `-p`.\n2. The fully formed file location of where you'd like to save the generated file, `-s`.\n\nTo get a feel for what you can use, run the `--help` command:\n```bash\n$ swift run ColorUp --help\n```\nHere is what a command would look like:\n```bash\n$ swift run ColorUp -p \"users/jordan/documents/anApp/assets.xcassets/\" -s \"users/jordan/documents/anApp/extensions/\"\n```\n\nIf the asset catalog has one color named \"MyColor\", the result would look like this for UIKit:\n```swift\n//\n//  ColorCatalogExtensions-UIKit.swift\n//\n//  GENERATED CODE: Any edits will be overwritten.\n//  Generated on Feb 21 2020\n//\n\nimport UIKit\n\nextension UIColor {    \n    class var MyColor : UIColor? {\n        return UIColor(named: \"MyColor\")\n    }\n}\n```\n\n...and for SwiftUI:\n```swift\n//\n//  ColorCatalogExtensions-SwiftUI.swift\n//\n//  GENERATED CODE: Any edits will be overwritten.\n//  Generated on Feb 21 2020\n//\n\nimport SwiftUI\n\nextension Color {    \n    static var MyColor : Color {\n        return Color(\"MyColor\")\n    }\n}\n```\n\nIf you'd like to run ColorUp from anywhere and not have to nagivate to its location on the file system, you build it for release and move it to the executable binaries folder:\n```bash\n$ swift build -c release\n$ cp .build/release/ColorUp /usr/local/bin/ColorUp\n```\n\nThis allows you to just open Terminal and run it from anywhere.\n### Options\n\n**Xcode Project: \u003cspan style=\"color: red;\"\u003eRequired\u003c/span\u003e**\n```bash\n--project \"path/to/project\"\n```\nThe complete path to the asset catalog that contains the colors you wish to generate an extension file for.\n\n**Save Location:\u003cspan style=\"color: red;\"\u003e Required\u003c/span\u003e**\n```bash\n--saveLocation \"path/to/save/extension\"\n```\nThe complete path where you wish to save the file at.\n\n**Use force unwrapping: Optional**\n```bash\n--forceUnwrap\n```\nUse this option to generate a force-unwrapped color call. Note that SwiftUI code will ignore this option, as it's `Color(name)` initializer doesn't produce an optional type.\nExample:\n```swift\nclass var MyColor : UIColor {\n  return UIColor(named: \"MyColor\")!\n}\n```\nversus the default:\n```swift\nclass var MyColor : UIColor? {\n  return UIColor(named: \"MyColor\")\n}\n```\n\n**Function Prefix: Optional**\n```bash\n-fp \"aPrefix\"\n```\nPuts the supplied string in front of the generated functions. \nExample:\n```swift\n// UIKit\nclass var aPrefixMyColor : UIColor {\n  return UIColor(named: \"MyColor\")!\n}\n\n// SwiftUI\nstatic var aPrefixMyColor: Color {\n  return Color(\"MyColor\")\n}\n```\nversus the default:\n```swift\n// UIKit\nclass var MyColor : UIColor? {\n  return UIColor(named: \"MyColor\")\n}\n\n// SwiftUI\nstatic var MyColor: Color {\n  return Color(\"MyColor\")\n}\n```\n\n**File Name: Optional**\n```bash\n--fileName \"GeneratedColors\"\n```\nThe name of the generated file containing the extensions. Defaults to `ColorCatalogExtensions-UIKit.swift` for UIKit, and `ColorCatalogExtensions-SwiftUI.swift` for SwiftUI. \n\n**Generate SwiftUI Code: Optional**\n```bash\n--SwiftUI \n```\nA `boolean`, if present the generated code is for SwiftUI's `Color` type. If not, it'll default to UIKit and `UIColor`.\n\n### Contributing\nColorUp welcomes anyone to contribute. Here's a quick start guide:\n\n### 1. Clone the project\n```bash\n$ git clone https://github.com/DreamingInBinary/ColorUp.git\n```\n\n### 2. Generate an Xcode Project\n```bash\n$ cd path/to/colorup\n$ swift package generate-xcodeproj\n```\n\n### 3. Build the Project\n```bash\n$ swift build \n```\n\n### 4. Run It\n```bash\n$ swift run ColorUp --saveLocation \"path/to/save/extension\" --project \"path/to/project\"\n```\n\nI find it's much easier to run it locally from an Xcode project and use the `CommandLineUtil` class to provide debug values using `debugValues()`.\n\nFor development, all the files you'll need to use are within `ColorUpCore`:\n1. `ColorUp.swift` runs the actual program, and has the code to generate the file.\n2. `CommandLineUtil.swift` houses logic to get input from the command the user has run, and houses them within `FileGenOptions`.\n\n\u003chr /\u003e\n\nAny questions? Feel free to reach out to on [Twitter](https://www.twitter.com/jordanmorgan10) or open an issue!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreaminginbinary%2Fcolorup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdreaminginbinary%2Fcolorup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreaminginbinary%2Fcolorup/lists"}