I have a project named XXX
. I want to rename this project to YYY
.
Note that XXX
is an extremely common term (for e.g. "data", or simply "project"), and thus a simple RegEx search-and-replace is not possible, out of risk of corrupting the project configuration files.
My current project directory contains the following items:
XXX
XXXTests
XXX.xcodeproj
and I want to rename them to:
YYY
YYYTests
YYY.xcodeproj
... respectively, with the necessary changes being reflected in my project file.
How can I accomplish this without having to manually create and populate a new project?
Edit: It is absolutely ridiculous that this has become my most upvoted question.
This question is related to
xcode
ide
rename
batch-rename
Extra instructions when following @Luke-West's + @Vaiden's solutions:
Also, I did not have to use step 3 of @Vaiden's solution. Just running rm -rf Pods/
in terminal got rid of all old pod files
I also did not have to use step 9 in @Vaiden's solution, instead I just removed the OLD project named framework under Link Binary Libraries (the NEWLY named framework was already there)
So the updated steps would be as follows:
Step 1 - Rename the project
Step 2 - Rename the Scheme
Step 3 - Rename the folder with your assets
Step 4 - Rename the Build plist data
Step 5 Handling Podfile
pod deintegrate
You should be able to build with no errors after you have followed all of the steps successfully
PLEASE cd
TO A NON-GIT REPOSITORY BEFORE PROCEEDING ??
/NewProjectFolder
OUTSIDE your git repository. ?? changes to .git could corrupt your git index ?Now we're going to rename the project from oldName
to NewProject
.
/NewProjectFolder
.cd /Path/to/your/NewProjectFolder
brew install rename ack
find . -name 'oldName*' -print0 | xargs -0 rename --subst-all 'oldName' 'NewProject'
find . -name 'oldName*'
ack --literal --files-with-matches 'oldName' --print0 | xargs -0 sed -i '' 's/oldName/NewProject/g'
ack --literal 'oldName'
pod install
NewProjectFolder
to your repository.There is a GitHub project called Xcode Project Renamer
:
It should be executed from inside root of Xcode project directory and called with two string parameters: $OLD_PROJECT_NAME & $NEW_PROJECT_NAME
Script goes through all the files and directories recursively, including Xcode project or workspace file and replaces all occurrences of $OLD_PROJECT_NAME string with $NEW_PROJECT_NAME string (both in each file's name and content).
To add to @luke-west 's excellent answer:
OLD.xcworkspace
to NEW.xcworkspace
.Podfile
from the project navigator. You should see a target
clause with the OLD name. Change it to NEW.OLD.podspec
file.rm -rf Pods/
pod install
.Build Phases
tab.Link Binary With Libraries
, look for libPods-OLD.a
and delete
it.Adding to the accepted answer by Luke West. If you have any entitlements:
XCode 11.0+.
It's really simple now. Just go to Project Navigator
left panel of the XCode window.
Press Enter
to make it active for rename, just like you change the folder name.
Just change the new name here, and XCode will ask you for renaming other pieces of stuff.
Tap on Rename
here and you are done.
If you are confused about your root folder name that why it's not changed, well it's just a folder. just renamed it with a new name.
To change the project name;
2.In the Identity and Type section of the File inspector, enter a new name into the Name field.
3.Press Return.
A dialog is displayed, listing the items in your project that can be renamed. The dialog includes a preview of how the items will appear after the change.
To selectively rename items, disable the checkboxes for any items you don’t want to rename. To rename only your app, leave the app selected and deselect all other items.
Press "Rename"
Aside from all the steps Luke and Vaiden recommended, I also had to rename all the customModule properties in my Storyboard to match the new name, and this has to be case sensitive.
Source: Stackoverflow.com