Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Xcode find/replace in XIBs?

Tags:

xcode

ios

xcode4

If I use Xcode's "Find/Replace in workspace" it seems to skip any text contained in the UIViews in XIB files.

Anyway to do this in Xcode or do I need to use another tool?

Thanks!

like image 681
sayguh Avatar asked Jan 20 '26 23:01

sayguh


2 Answers

XCode will successfully Refactor IBOutlet names even if they are connected up in the nib. So to answer you:

Before choosing Find/Replace on the text, first see if Xcode will Refactor it instead. It won't refactor certain things (such as enums and #defines). If it will Refactor your target text then choose that and it should be okay.

like image 63
Damo Avatar answered Jan 23 '26 12:01

Damo


You can use find and sed from the command line

find . -name '*.xib' -type f -exec sed -i "" 's/OldText/NewText/g' {} \

For instance, I just had to find and replace all class prefixed from SC to MCSC and I used:

find . -name '*.xib' -type f -exec sed -i "" 's/[[:<:]]SC/MCSC/g' {} \

The [[:<:]] indicates a word boundary on OS X (see https://stackoverflow.com/a/5734237/456366).

like image 40
Richard Venable Avatar answered Jan 23 '26 12:01

Richard Venable