skip to Main Content

I have a quite a few colors to add to my assets folder. They’re all in Hexadecimal form. In the Attributes inspector > Color > there is ‘Input Method‘. By default it is set to ‘Floating Point’. I know I can change this to ‘8-bit Hexadecimal’, but I’d rather not do this by hand every time I add a color. Not to mention that I’d have to do this twice per color. Once for the ‘Any’/light appearance and again for the ‘dark’.

Is there a way to change the default input method?

2

Answers


  1. I found a small hack for changing that and I’m not sure how reliable that is:

    1. Go to /Applications/Xcode.app/Contents/Frameworks/AssetCatalogKit.framework/Versions/A/Resources/

    2. Open IBICColorSetRep.inspector with any text editor

    3. in <section visibleKeyPath="localContentController.selection.ibInspectedShowRGBASliders"> change:

      3.1. <choice value="0" title="Floating point (0.0-1.0)"> to <choice value="2" title="Floating point (0.0-1.0)">

      3.2. <choice value="2" title="8-bit Hexadecimal"> to <choice value="0" title="8-bit Hexadecimal">

    If you install a new Xcode Version you need to change it again. Best solution to that is making a backup and paste it into the same directory again after updating Xcode.

    Login or Signup to reply.
  2. Too long to add a comment so I’m adding as an answer here:

    I found a problem with the approach from @Carsten. Looks like the color value is not stored in the same representation in the Contents.json file when you change those constants in the inspector configuration file.

    Xcode stores each color in the format it was entered. So hex colors are stored like:

         "color" : {
            "color-space" : "srgb",
            "components" : {
              "alpha" : "1.000",
              "blue" : "0xFC",
              "green" : "0xFD",
              "red" : "0xFF"
            }
          },
    

    and floating point are stored like:

         "color" : {
            "color-space" : "srgb",
            "components" : {
              "alpha" : "1.000",
              "blue" : "0.118",
              "green" : "0.110",
              "red" : "0.110"
            }
          },
    

    And if you make the change suggested, it stores them in the opposite representation.
    This can be a problem since the rounding can be off and you could get a different color than you expect if the hex is converted to floating point and then back. Depends on the color value.

    There may be more editing of the inspector files that could be done to fix this, but I’m not going to dive in right now. You never know if the Xcode codebase is using those constants and not pulling them from the file.

    Safer to do the old painful way and know that your colors are accurate. 🙁

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search