How to mass-rename files/change prefix in Xcode

Let’s say you created a BOOMWackadoo project. You’ve been working on it for a while, and now have a ton of files starting with “BOOMWackadoo,” as well as a ton of BOOMWackadoo references in code. One day a friend says, “Why don’t you just remove BOOM? Wackadoo seems cool enough.” If you realize your friend is right, here’s how you implement the advice:

  1. If you specified you project’s prefix as “BOOM” when you created the project, change it to an empty string as shown here. (The UI is the same for Xcode 5 as it was for Xcode 4) Now close your project in Xcode.
  2. Time to mass-rename all your files on disk. Download the Automator template linked to at the end of this article and run it. Make sure that in “Rename Finder Items: Replace Text” workflow you select “full name” from the drop-down to the right of “Find” text field. FYI, I had to run this Automator template twice to get all the files renamed, for some reason.
  3. Now that you’ve renamed all the files, it’s time to change all the references in your .xcodeproj file! Open your Wackadoo.xcodeproj file in some sort of real editor, like Sublime Text 2. (Notice that step above renamed the file from BOOMWackadoo.xcodeproj to Wackadoo.xcodeproj.) In the side bar, right-click on Wackadoo.xcodeproj and select ‘Find in Folder…’ Type BOOMWackadoo in the Find field and Wackadoo in the Replace field. Push “Case Sensitive” button on the left (unless your file name casing isn’t consistent, in which case shame on you). Hit Replace, confirm. Make sure to save the changes! Now you can close Sublime.
  4. Finally, we need to change all the code references. Open your Wackadoo project in Xcode and don’t try to build lest you just like the color red. Press Command + 3 to open the Find Navigator view (or click the magnifying glass icon at the top of the Navigator side bar). Tap the “Find” text above the first text box and select Replace > Text > Starting with, then type “BOOMWackadoo” (the old name) in the search box, hit Enter. This will search for all occurrences and enable the Replace All button. But first type “Wackadoo” in the “With” text box. Now hit Replace All (if it asks if you want to enable snapshots and create one, what you pick is up to you). Screenshot of Find/Replace in Xcode

Das is it! You should be able to build and run your “BOOM”-less project now.