RMRColorTools-iOS icon indicating copy to clipboard operation
RMRColorTools-iOS copied to clipboard

Colors are not updated in storyboard after changing values in ".clr" file.

Open Visput opened this issue 10 years ago • 4 comments

I tried to use this tool. It works as expected except one thing: Colors are not updated in storyboard after changing values in ".clr" file.

Steps to reproduce:

  1. Install RMRHexColorGen and RMRRefreshColorPanelPlugin.xcplugin as described in ReadMe.
  2. Create AppPalette.clr file with contents: FFFFFFFF app.
  3. Call RMRHexColorGen with all necessary parameters and build project.
  4. As result UIColor+AppPalette category is created and AppPalette color palette is appeared in interface builder.
  5. Open storyboard and set background color for any view by using appColor from AppPalette color palette.
  6. As result FFFFFFFF color is applied to view.
  7. Change contents of AppPalette.clr to this: FFAAAAAA app.
  8. Call RMRHexColorGen with all necessary parameters and build project.

Actual behavior: appColor value is updated to FFAAAAAA in:

  1. UIColor+AppPalette category.
  2. AppPalette color palette in interface builder. But background color of my view in storyboard isn't updated. It still has FFFFFFFF color.

Expected behavior: appColor value is updated in all places:

  1. UIColor+AppPalette category.
  2. AppPalette color palette in interface builder.
  3. In all views where this color is used in storyboards / xibs.

System configuration: OS X El Capitan 10.11.1, Xcode 7.1.1 (7B1005).

So it means that if one of my colors are changed then I have to manually update it in all views placed in storyboard / xibs. I don't know if it's possible to fix this issue because *.storyboard file contains RBGA values for colors instead of reference to color name in palette.

Do you have any workaround for this issue?

Visput avatar Nov 20 '15 08:11 Visput

Unfortunately, as you say, Xcode xib and storyboard formats do not allow completely automate this process. But here you can find python script to search and replace colors inside xib/storyboard files.

I'll be glad to discuss any ideas around this problem if you have some.

firmach avatar Nov 30 '15 17:11 firmach

Thanks for reference to script. So why can't you utilize this script for RMRHexColorGen? I mean such scenario:

  1. RMRHexColorGen is launched (I use it as build phase in project, so UIColor category will be updated during building process if some values changed in .clr file).
  2. RMRHexColorGen checks if .clr file was changed since previous execution (tool should cache last used .clr file).
  3. If .clr was changed then RMRHexColorGen updates UIColor category and updates colors in all xibs and storyboards (path to project can be provided as tool argument). Colors can be updated in this way: RMRHexColorGen runs xibcolor with parameters: 1) old value from .clr file; 2) new value from .clr file; 3) path to xib or storyboard. This process should recursively repeated for every changed color and for every xib and storyboard.

Visput avatar Nov 30 '15 18:11 Visput

Yes, we've already thought about it. But we are not 100% sure about this script. Got no time to test it and author writes that you should be careful with it, cuz it can broke IB file.

firmach avatar Dec 07 '15 08:12 firmach

Hello! I just faced this and created this swift script as a workaround, I know 7 years later, but maybe it helps someone in the future https://github.com/Mabas/NibColorUpdater

Mabas avatar Oct 12 '22 05:10 Mabas