Colors are not updated in storyboard after changing values in ".clr" file.
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:
- Install
RMRHexColorGenandRMRRefreshColorPanelPlugin.xcpluginas described in ReadMe. - Create
AppPalette.clrfile with contents:FFFFFFFF app. - Call
RMRHexColorGenwith all necessary parameters and build project. - As result
UIColor+AppPalettecategory is created andAppPalettecolor palette is appeared in interface builder. - Open storyboard and set background color for any view by using
appColorfromAppPalettecolor palette. - As result
FFFFFFFFcolor is applied to view. - Change contents of
AppPalette.clrto this:FFAAAAAA app. - Call
RMRHexColorGenwith all necessary parameters and build project.
Actual behavior:
appColor value is updated to FFAAAAAA in:
-
UIColor+AppPalettecategory. -
AppPalettecolor palette in interface builder. But background color of my view in storyboard isn't updated. It still hasFFFFFFFFcolor.
Expected behavior:
appColor value is updated in all places:
-
UIColor+AppPalettecategory. -
AppPalettecolor palette in interface builder. - 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?
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.
Thanks for reference to script. So why can't you utilize this script for RMRHexColorGen? I mean such scenario:
- 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).
- RMRHexColorGen checks if .clr file was changed since previous execution (tool should cache last used .clr file).
- 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.
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.
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