sayguh
sayguh

Reputation: 2550

Can Xcode find/replace in XIBs?

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!

Upvotes: 3

Views: 1104

Answers (4)

Richard Venable
Richard Venable

Reputation: 8695

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).

Upvotes: 2

Damo
Damo

Reputation: 12900

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.

Upvotes: 2

Rok Jarc
Rok Jarc

Reputation: 18875

If you really have a lot of this text you want to find/replace, you might find IBTool usefull.

It's usually used to export/import texts from/into .XIB for translation reasons, but it should fit your needs, too.

You can see example of IBTool usage on iPhone Applications Localization Guide. You'd be interested in points 2 and 5 of the guide.

  • you export the strings using IBTool
  • you do find/replace in any text editor
  • you reimport the string

Upvotes: 1

rishi
rishi

Reputation: 11839

Find and replace option of Xcode if for text/string replacement not for files.

If you want to do this you can have your shell script/ apple script.

Upvotes: 1

Related Questions