如何重命名xcode项目中的文件夹名而不破坏文件

时间:2022-10-26 10:33:34

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

在我的xcode项目中,我创建了一个手动命名为“MyClasses”的文件夹,将新添加的文件/类放置到这个文件夹中。

Now i have nearly 30 classes in this folder.

现在我在这个文件夹中有将近30个类。

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

当我重命名此文件夹时,此文件夹中的所有文件将被删除。

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

现在我需要将文件夹重命名为“ViewControllerClasses”。

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

但是我丢失了30。h。m。xib文件。[幸运的是我有一个拷贝和压缩文件]

How to rename the folder with out corrupting the files.

如何重命名文件夹而不破坏文件。

如何重命名xcode项目中的文件夹名而不破坏文件

如何重命名xcode项目中的文件夹名而不破坏文件

Renamed it to myviewcontrollerclasswes

重命名它myviewcontrollerclasswes

When i renamed

当我重命名

如何重命名xcode项目中的文件夹名而不破坏文件如何重命名xcode项目中的文件夹名而不破坏文件

4 个解决方案

#1


15  

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

从2017年开始注意:现在Xcode 9将自动同步文件夹和项目层次结构。

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

截至2013年的注意事项:复制并重命名Xcode项目及相关文件夹


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.

项目文件下的XCode中的“文件夹”不是文件系统中的真正文件夹,而是.xcodeproj文件中管理的虚拟文件夹。您可以独立于文件系统中的文件位置来组织项目文件夹中的文件。有些人喜欢将文件系统文件夹结构映射到项目文件夹结构中,有些人将所有源文件存储在文件系统的一个大文件夹中,并只在项目文件夹中组织它们:这是一个优先考虑的问题。

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.

但是,如果您重命名/移动文件系统中的文件,您将不得不删除并重新添加到项目中,因为XCode不知道在哪里找到它们。注意不要从物理上删除它们,只从XCode项目中删除它们,然后重新添加它们,并根据需要重新组织。

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.

还有一件事要注意:如果你使用的是版本控制系统,你将不得不通知它的客户(很可能是svn或git),你已经重命名/移动了你的文件。如果您想保存文件修订历史,最好将copy/move命令显式地发送到版本控制,否则它会将您的文件从旧位置删除,并在新位置添加为新。

#2


24  

Two Solutions

两种解决方案

Method_1. Try Manual editing:

Method_1。试着手工编辑:

  « 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:

Method_2。使用Xcode选择基本文件夹:

Rename folder in finder then use Xcode to choose same folder. 如何重命名xcode项目中的文件夹名而不破坏文件

在finder中重命名文件夹,然后使用Xcode选择相同的文件夹。

#3


3  

You should just run a search and replace on the project file (if you are working with version control and with other developers you will have seen this file a lot without a doubt), it's the project.pbxproj file located inside the xxxxxxxx.xcodeproj file.

您应该在项目文件上运行搜索和替换(如果您正在使用版本控制,并且与其他开发人员一起工作,您肯定会经常看到这个文件),这就是项目。位于xxxxxx中的pbxproj文件。xcodeproj文件。

Just right click (Control + Click) on the file and select "Show Package Contents" to find the xcodeproj file.

只需在文件上右键单击(控制+单击),然后选择“显示包内容”以找到xcodeproj文件。

#4


3  

In case anyone is still having trouble with this:

如果还有人对此有疑问:

  1. Select the folder or file in the left-side bar of XCode corresponding to the folder you want to rename (for me I renamed the folder containing all my files so I selected the topmost folder)
  2. 在XCode的左侧栏中选择与要重命名的文件夹对应的文件夹或文件(对于我,我重命名了包含我所有文件的文件夹,因此我选择了最上面的文件夹)
  3. On the right-side bar, below where it says 'Location', click the folder icon.
  4. 在右边的栏,在下面写着“位置”的地方,点击文件夹图标。
  5. In the file explorer that opens up rename the existing folder to whatever name you'd like it to be, then afterwards select it and press 'Ok'.
  6. 在打开的文件资源管理器中,将现有文件夹重命名为您想要的名称,然后选择它并按“Ok”。
  7. XCode should update the file locations accordingly.
  8. XCode应该相应地更新文件位置。

Keep in mind that if you rename something which contains a file that is hard-coded as a certain path in your build settings, XCode will throw an error. You'll have to manually change those paths in your build settings.

请记住,如果重命名包含硬编码为构建设置中的特定路径的文件,XCode将抛出一个错误。您将不得不在构建设置中手动更改这些路径。

This worked for me, hope it works for you too.

这对我有用,希望对你也有用。

#1


15  

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

从2017年开始注意:现在Xcode 9将自动同步文件夹和项目层次结构。

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

截至2013年的注意事项:复制并重命名Xcode项目及相关文件夹


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.

项目文件下的XCode中的“文件夹”不是文件系统中的真正文件夹,而是.xcodeproj文件中管理的虚拟文件夹。您可以独立于文件系统中的文件位置来组织项目文件夹中的文件。有些人喜欢将文件系统文件夹结构映射到项目文件夹结构中,有些人将所有源文件存储在文件系统的一个大文件夹中,并只在项目文件夹中组织它们:这是一个优先考虑的问题。

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.

但是,如果您重命名/移动文件系统中的文件,您将不得不删除并重新添加到项目中,因为XCode不知道在哪里找到它们。注意不要从物理上删除它们,只从XCode项目中删除它们,然后重新添加它们,并根据需要重新组织。

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.

还有一件事要注意:如果你使用的是版本控制系统,你将不得不通知它的客户(很可能是svn或git),你已经重命名/移动了你的文件。如果您想保存文件修订历史,最好将copy/move命令显式地发送到版本控制,否则它会将您的文件从旧位置删除,并在新位置添加为新。

#2


24  

Two Solutions

两种解决方案

Method_1. Try Manual editing:

Method_1。试着手工编辑:

  « 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:

Method_2。使用Xcode选择基本文件夹:

Rename folder in finder then use Xcode to choose same folder. 如何重命名xcode项目中的文件夹名而不破坏文件

在finder中重命名文件夹,然后使用Xcode选择相同的文件夹。

#3


3  

You should just run a search and replace on the project file (if you are working with version control and with other developers you will have seen this file a lot without a doubt), it's the project.pbxproj file located inside the xxxxxxxx.xcodeproj file.

您应该在项目文件上运行搜索和替换(如果您正在使用版本控制,并且与其他开发人员一起工作,您肯定会经常看到这个文件),这就是项目。位于xxxxxx中的pbxproj文件。xcodeproj文件。

Just right click (Control + Click) on the file and select "Show Package Contents" to find the xcodeproj file.

只需在文件上右键单击(控制+单击),然后选择“显示包内容”以找到xcodeproj文件。

#4


3  

In case anyone is still having trouble with this:

如果还有人对此有疑问:

  1. Select the folder or file in the left-side bar of XCode corresponding to the folder you want to rename (for me I renamed the folder containing all my files so I selected the topmost folder)
  2. 在XCode的左侧栏中选择与要重命名的文件夹对应的文件夹或文件(对于我,我重命名了包含我所有文件的文件夹,因此我选择了最上面的文件夹)
  3. On the right-side bar, below where it says 'Location', click the folder icon.
  4. 在右边的栏,在下面写着“位置”的地方,点击文件夹图标。
  5. In the file explorer that opens up rename the existing folder to whatever name you'd like it to be, then afterwards select it and press 'Ok'.
  6. 在打开的文件资源管理器中,将现有文件夹重命名为您想要的名称,然后选择它并按“Ok”。
  7. XCode should update the file locations accordingly.
  8. XCode应该相应地更新文件位置。

Keep in mind that if you rename something which contains a file that is hard-coded as a certain path in your build settings, XCode will throw an error. You'll have to manually change those paths in your build settings.

请记住,如果重命名包含硬编码为构建设置中的特定路径的文件,XCode将抛出一个错误。您将不得不在构建设置中手动更改这些路径。

This worked for me, hope it works for you too.

这对我有用,希望对你也有用。