问题描述
我知道如何在Xcode 4中重命名项目,但是如何重命名源文件夹?事实是,在Xcode中重命名项目只会在Xcode中重命名(尽管与以前相比是进步的)-但是Xcode为什么不重命名我不知道的文件系统中的文件夹。
I know how to rename the project in Xcode 4, but how do you rename the source folder? The thing is that renaming the project in Xcode, does only rename within Xcode (Though it is progress compared to previous) - but why Xcode is not renaming the folder in the filesystem I don't know.
推荐答案
您可以在Xcode中执行此操作,而无需在文本编辑器中手动编辑pbxproj文件!
You can do this from within Xcode without resorting to hand editing the pbxproj file in a text editor!
方法如下:
-
在Finder中重命名源文件夹。最初,这会破坏项目,因为Xcode不会自动检测到虚拟(黄色)项目文件夹指向的实际文件夹的更改时间,因此该文件夹内的所有文件在Xcode中都会变成红色。不必担心,我们将在步骤3中对其进行修复。
Rename your source folder in the Finder. This will break the project initially because Xcode doesn't automatically detect when the real folders that the virtual (yellow) project folders point to are changed, so all the files inside that folder will turn red in Xcode. Don't worry about that, we'll fix it in step 3.
在Xcode中,点击左侧(现在已损坏)的虚拟文件夹,手动添加侧边栏并将其重命名以与Finder中的名称匹配(您实际上可以将其命名为任意名称,也可以根本不重命名,但这太疯狂了)。那样不能修复文件夹中的红色文件,但是可以。
In Xcode, click on the (now broken) virtual folder in the left-hand sidebar and rename it to match the name in the Finder (you can actually call it anything you want, or not rename it at all, but that would be insane). That won't fix the red files inside the folder, but that's OK.
在Xcode的右侧栏中,单击屏幕快照中显示的图标下面弹出一个文件对话框。选择您以前重命名的文件夹。这样会将虚拟文件夹与磁盘上的真实文件夹重新关联,并将自动修复指向其中所有文件的链接。
In the right-hand sidebar in Xcode, click the icon shown in the screenshot below to bring up a file dialog. Select the folder that you previously renamed. This will re-associate the virtual folder with the real folder on disk, and will automatically fix the links to all the files inside.
在您的构建设置中,搜索旧的文件夹名称,然后手动重命名找到的所有匹配项。通常会有两个,oldfolder / prefix.pch和oldfolder / info.plist,但可能还有其他两个。
In your build settings, search for the old folder name and manually rename any occurrences you find. There will typically be two of them, oldfolder/prefix.pch and oldfolder/info.plist, but there may be others.
全部完成!
编辑:此选项在Xcode 5中仍然存在,但默认情况下会有用地隐藏。要显示它,请在文本设置面板上方的检查器中单击稀薄的身份和类型标题以将其展开。
this option is still there in Xcode 5, but is helpfully hidden by default. To show it, click the thin "Identity and Type" header in the inspector above the "Text Settings" panel to expand it.
这篇关于重命名xcode 4项目和实际文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!