Article source: www.cnblogs.com/GarveyCalvi…
Introduction: In IOS development, sometimes want to change the name of the project, will encounter a lot of trouble. Just change the project name, XCODE won’t change all the names for you. There are always many files, folders, or items for project Settings. And they can not be arbitrarily changed, sometimes change the change, do not compile. So when you rename your project, make a backup copy. In this article, I will introduce a method, which is a summary of my own reference to many sources.
Why is it complete? Because after the name is changed, you won’t see anything about the previous project name.
This article changes the name of a project from “test233333333” to “test”.
1) Open the project:
The above is the current project structure.
2) Select the project Settings and press Enter to enter the new project name:
3) After input, press Enter to display the file pairs before and after Rename, and then click “Rename” :
4) A dialog box will pop up, click “Enable” directly:
5) You’ll notice that there are many files/folders with “old” project names:
Never mind, read on to wipe out these “old” names together.
6) Let’s change the names of these two folders:
Before the change:
After the change:
TestTests, here for the original test233333333Tests, we need to pay attention to when to change the name, only need to put the old name (test233333333) (test) can be replaced with a new name, don’t put the other characters (Tests) deleted!
7) Select this class file and use Xcode’s built-in function to change the name of the class.
Click the class name after @interface:
Follow the following steps (Edit->Refactor->Rename) :
Enter a new class name:
Click Save:
8) Let’s look at our directory structure again, we have all changed, but now the compilation will not pass:
XCode failed to find the connection file:
This is because there are still many project Settings that need to be renamed, and currently Xcode still points to the same project name.
10) Search the previous project name globally and replace it with the new project name:
Note: this is just to replace the comments, the actual project Settings need to be done manually.
11) The interface for searching the name of the old project globally, we click in to change the name:
After clicking, it will automatically jump to this interface. Double-click the value to change it (the following steps for renaming are also the same) :
After that, I have to make some more changes. Don’t ask why it’s so much trouble, just because it’s willful.
Note: Continue global search and replace until the old name is not found in global search!
12) Open the project folder and continue the rename:
After the name change:
Go back to the project and look, the file is all red. Never mind, normal:
13) Change the resource folder path of the corresponding folder:
13.1) Select the test folder:
13.2) Click the small folder icon to change the path:
Locate the file with the changed name and click Choose. The next folder (testTests) step repeats the above.
Once it’s done, Build again, and it’s passed.
Screenshot of the complete rename of the project:
Project Structure:
Project real directory structure:
Summary: friends who have not changed the project, remember to back up before changing oh.
\