Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/artem-y/hexcode

A tool that finds Xcode color assets by hex code
https://github.com/artem-y/hexcode

cli color-assets hex ios macos rgb swift-package-manager tvos visionos watchos xcode xcodeproj xcworkspace

Last synced: 13 days ago
JSON representation

A tool that finds Xcode color assets by hex code

Awesome Lists containing this project

README

        




A tool that finds Xcode color assets by their hex codes. The idea behind this tool is to speed up and ease the process of finding assets that were already added to the project. This helps prevent accidental duplication when there are too many color assets to go through and they are easy to miss because they have different component representations.







### ⚠️Disclaimer:
For now, the tool only supports searching for exact values of color components as ints, floats or hexadecimals, without conversion between settings like content type (sRGB, Display P3, Gray Gamma 2.2 etc.), and ignoring some other settings like Gamut etc.
## Usage
The tool can be used like this from terminal:
```
hexcode #ffa500
```
...where `#ffa500` is a hex color code, with or without `#`, case-insensitive.

This way `hexcode` will recursively search for the color assets matching the hex rgb value, starting from current directory. The output will be one or more matching color set names, or a message notifying that it haven't found an asset with the given color. The command also has some very simple error handling and might exit with error.
More arguments and options will be added in the future with new features, they can be found using the `--help` flag.
#### Examples
Color found:
hexcode_usage_color_found

Color not found:
hexcode_usage_no_such_color

## Installation
1. Clone the repository to your machine
2. Assuming the folder name "hexcode" has not changed, run in terminal:
```
cd hexcode
```
### Using Swift Package Manager:
Then run the following:
```
swift build -c release
mv .build/release/hexcode /usr/local/bin
```
(you might need `sudo` before the `mv` command, depending on your machine's configuration)

3. Run `which hexcode` to make sure it is now visible

Alternatively, it can be moved to some directory other than `/usr/local/bin`, just make sure that directory is included in `$PATH` if you want it visible from anywhere in terminal.
Or you can just run it as an executable Swift package [without installation](#running-without-installation), using Swift Package Manager commands.
### Using make:
From the root of the repository, run the following command:
```
sudo make install
```
If you want to install it into a directory other than default `/usr/local/bin`, replace it in the `Makefile` with your target directory.
Just make sure it's added to the PATH.
### Running without installation:
From the `hexcode` directory (or passing it as `--package-path`), the command can be run as executable package without previous installation, for example:
```
swift run hexcode e8de2a --directory=$HOME/Documents/myProject
```
## Testing


- "If it is not tested, I will send it back."

- "If tests don't pass, I will send it back."

Tests should work both from Xcode (Cmd+U after opening `Package.swift`) and Terminal:
```
swift test
```
Core logic must be covered with tests that help decrease regression when developing new features, and also help understand how the app works.