How do I completely rename an Xcode project (i.e. inclusive of folders)?


I have a project named SampleDemo I want to rename this project to Sample9to5iOSExample, it includes pod file as well

My current project directory contains the following items:

  • SampleDemo
  • SampleDemoTests
  • SampleDemo.xcodeproj

and the output to rename them will be:

  • Sample9to5iOSExample
  • Sample9to5iOSExampleTests
  • Sample9to5iOSExample.xcodeproj


 Here is using terminal we can do it easily

A quicker solution using shell commands (works with CocoaPods too):


Step 1 – Prerequisites

  1. Copy your original project folder to a temporary /NewProjectFolder OUTSIDE your git repository.  changes to .git could corrupt your git index 💥

Step 2 – Open Terminal

Now we’re going to rename the project from oldName to NewProject.

  • Close XCode.
  • Go to your /Sample9to5iOSExample.

cd /Path/to/your/Sample9to5iOSExample

  • Install the extra tools needed.

brew install rename ack

  • Rename the files and directories containing the source string. You’ll need to RUN THIS COMMAND TWICE, because directories will be renamed first, then files and directories inside those will be renamed on the next iteration.

find . -name ‘SampleDemo*’ -print0 | xargs -0 rename –subst-all ‘oldName’ ‘Sample9to5iOSExample’

  • Check if all the files containing the source string are renamed. You should see empty output.

find . -name ‘SampleDemo*’

  • Replace all occurrences of the string in all files.

ack –literal –files-with-matches ‘SampleDemo’ –print0 | xargs -0 sed -i ” ‘s/oldName/Sample9to5iOSExample/g’

  • Check if all occurrences of the string in all files were replaced. You should see empty output.

ack –literal ‘oldName’

  • Run pod install
  • Add NewProjectFolder to your repository.
  • You are done!

Add a Comment

Your email address will not be published. Required fields are marked *