iOS - Change color name in all XIBs or Storyboards

43 views Asked by At

How can I replace a specific color defined in Xcode and used in multiple XIBs and storyboards with a different color throughout the project?

Example : How can I replace the color "MainPurple" with "MainYellow" in all XIBs and storyboards in Xcode where it is currently used, while ensuring that the change is applied consistently across the entire project?

1

There are 1 answers

0
el3ankaboot On BEST ANSWER

Using the terminal, Navigate to the project and run this command:

find . -type f \( -name '*.xib' -or -name '*.storyboard' \) \

  -exec sed -E -i '' 's/([cC]olor.*)name="MainPurple"/\1name="MainYellow"/' {} \;

This searches in all XIBs and Storyboards for the color "MainPurple" whether used as a view color, button color, label color and so on , and replaces it with "MainYellow"