Complete rename Method for iOS Projects

Source: Internet
Author: User

Complete rename Method for iOS Projects

In iOS development, it may be a lot of trouble 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) Let's try to Build it,XCode reported this error and the connection file could not be found:

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:

Conclusion: if you have not changed the project, back up the project before you change it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.