Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename the folder name in xcode project with out corrupting the files

In my xcode project i have created a folder manually named "MyClasses" to place the newly added files/classes to this folder.

Now i have nearly 30 classes in this folder.

when i renamed this folder , all the files in this folder are gets Erased.

Now i need to rename the folder to "ViewControllerClasses".

But i lost 30 .h, .m, xib files. [lucky i have a copy & and zip file]

How to rename the folder with out corrupting the files.

enter image description here

enter image description here

Renamed it to myviewcontrollerclasswes

When i renamed

enter image description hereenter image description here

like image 318
Ranga Avatar asked Apr 04 '12 07:04

Ranga


People also ask

How do I rename an Xcode project without losing my mind?

Select the project you want to rename in the “Project Navigator” which can be found on the left side of the Xcode view. On the right-hand side of the window, select the “File Inspector”. The name of your project should be in there under “Identity and Type”, change it to “NEW” and press Enter.

How do I completely rename an Xcode project?

Click on the project you want to rename in the "Project navigator" in the left panel of the Xcode window. In the right panel, select the "File inspector", and the name of your project should be found under "Identity and Type". Change it to your new name.

Can you rename files in Xcode?

Open the Inspectors Area (on the top-right corner). And then open up File Inspector. There you'll find the name field, where you can edit file's name.


2 Answers

Two Solutions

Method_1. Try Manual editing:

  « Drag your MedChart.xcodeproj to TextWrangler  (or any text editor) 

  « Use find button to find "FolderName" (Your folder name) 

  « Replace all with new name.

  « In some project you may notice header search path problem...goto header search path and replace with new name.

Method_2. Use Xcode to choose base folder:

Rename folder in finder then use Xcode to choose same folder. enter image description here

like image 192
Guru Avatar answered Sep 21 '22 20:09

Guru


NOTE as of 2017: Now Xcode 9 synchronises the folder and the project hierarchy automatically.

NOTE as of 2013: Duplicate and rename Xcode project & associated folders


The "folders" what you see in XCode under your project file are not real folders in the file system, only virtual folders administered in the .xcodeproj file. You can organize your files in the project folder independently from their location in the file system. Some prefers to map the file system folder structure inside the project folder structure, some others store all source files in one big folder in the file system and organize them only in the project folders: it's rather a question of preference.

However if you rename/move physically the files in the file system, you will have to delete and re-add them to your project since XCode will not know where to find them. Pay attention not to delete them physically only remove them from XCode project, then re-add them and reorganize as you want.

One more thing to note: if you are using version control system you will have to inform also its client (svn or git most likely) that you have renamed/moved your files. If you want to keep file revision history it will be a good idea to issue the copy/move command explicitly to the version control otherwise it will treat your files as deleted from the old location and added as new in the new location.

like image 40
MrTJ Avatar answered Sep 19 '22 20:09

MrTJ