IOS development-Project Rename (graphic details)
In IOS development, sometimes it is difficult to change the project name. Change the project name directly, and XCODE won't help you change all the names. There are always many files, folders, or project settings. In addition, it cannot be changed at will. Sometimes it cannot be changed or compiled. So when you rename a project, remember to back up a copy first. In this article, I will introduce a method that I have summarized based on a lot of materials.
Why is it complete? Because after the name is changed, you will no longer see any name about the previous project.
This article will change a project named "test233333333" to "test ".
1) Open a project:
The above is the current project structure.
2) Select the Project Settings and press enter to enter the new Project name:
3) after entering the name, press enter to display the object name before and after renaming. Then, click "Rename ":
4) A dialog box will pop up, and click "Enable ":
5) you will find that there are still many files/folders with the name of the old project:
It doesn't matter. Let's continue to look down and eliminate these old names together.
6) change the names of these two folders first:
Before modification:
After modification:
Here, testTests is originally test2333333tests. When we change the name, we only need to replace the old name (test233333333) with the new name (test). Do not delete other characters (Tests!
7) When selecting this class file, you cannot rename the class name directly. You need to use the built-in function of Xcode to change the Class Name:
Click the class name after @ interface:
Follow these steps (Edit-> Refactor-> Rename ):
Enter a new class name:
Click Save:
8) let's take a look at our directory structure, which has all been changed, but the compilation won't pass now:
9) We tried to Build it. XCode reported this error and could not find the connection file:
This is because many other project settings need to be changed. Currently, Xcode still points to the previous project name.
10) Globally search for the previous project name and replace it with the new Project name:
Note: Here we only need to replace the comments. manual operations are required for real project settings.
11) on the global search page for the old project name, click here to change the name:
After you click it, the page is automatically displayed. Double-click the value to change it (the steps for renaming are the same below ):
After the change, you have to modify something. Don't ask why it is so troublesome, just because it is willful.
Note: Continue to replace the global search until the old name cannot be found globally!
12) Open the project folder and rename it:
After renaming:
Go back to the project and check that all files are "red. It doesn't matter. Normal:
13) change the resource folder path of the corresponding folder:
13.1) Select the test Folder:
13.2) Click the folder icon to change the path:
Find the file whose name has been changed and click choose. The next folder (testTests) steps are repeated above.
After modification, Build again, and then pass.
After the project is fully renamed:
Project Structure:
Project real directory structure:
Summary: if you have not changed the project, back up the project before you change it.