如何更改 xcode 项目中文件的位置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19020582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I change the location of files in xcode project?
提问by icemelon
I put some files on the same level of *.xcodeproj
file carelessly. When I move these files into the right location in Finder, Xcode tells me that these files are missing. So I delete the group which contains these files whose names have been read (I realize it is a mistake). And I drag these files from Finder into the xcode to build a new group. But when I try to run the project, Xcode still can't find these code. How can I solve the problem?
我*.xcodeproj
不小心将一些文件放在同一级别的文件中。当我将这些文件移动到 Finder 中的正确位置时,Xcode 告诉我这些文件丢失了。所以我删除了包含这些名称已被读取的文件的组(我意识到这是一个错误)。我将这些文件从 Finder 拖到 xcode 中以构建一个新组。但是当我尝试运行该项目时,Xcode 仍然找不到这些代码。我该如何解决问题?
回答by Michael Dautermann
When you see a file that is red (or in the wrong place), you can easily correct the location of these files by using the file inspector (which appears along the right side panel of your Xcode window).
当您看到一个红色的文件(或在错误的位置)时,您可以使用文件检查器(出现在 Xcode 窗口的右侧面板)轻松地更正这些文件的位置。
It looks like this:
它看起来像这样:
Clicking on the Folder icon next to the name will bring up an open panel from which you can choose the correct location of the file.
单击名称旁边的文件夹图标将打开一个打开的面板,您可以从中选择文件的正确位置。
回答by accfews
There is an easier way to re-organize files through the Xcode project. You can use Synx
, it automatically fixes file paths, through the Xcode project groups.
有一种更简单的方法可以通过 Xcode 项目重新组织文件。您可以使用Synx
,它会通过 Xcode 项目组自动修复文件路径。
You can check Github page for Synx
你可以在 Github 页面上查看 Synx
After intalling Synx just run the command below
安装 Synx 后只需运行以下命令
synx path/to/my/project.xcodeproj
synx path/to/my/project.xcodeproj
回答by pDwanLearner
I found the answer.
我找到了答案。
3 things
3件事
1 removed the reference to the red files then dragged them back into the project relinked all my .m and .h files just incase
1 删除了对红色文件的引用,然后将它们拖回项目中重新链接了我所有的 .m 和 .h 文件以防万一
2 then removed the .app reference and dragged it back in to the project.
2 然后删除 .app 引用并将其拖回项目中。
3 removed any duplicates or red files in the build phases
3 删除了构建阶段中的任何重复文件或红色文件
Fixed Thanks everyone for your suggestions and help
固定感谢大家的建议和帮助
回答by Ilker Baltaci
From my point of view i would definitely avoid the virtual folders in the Xcode.The disadventage of this approach is whe nthe project gets bigger and bigger you can not find corresponding files in your filesystem easy.Even you click on "Show in finder" you need to look for the file among tens of files.
从我的角度来看,我肯定会避免 Xcode 中的虚拟文件夹。这种方法的缺点是当项目变得越来越大时,您无法轻松地在文件系统中找到相应的文件。即使您单击“在查找器中显示”需要在几十个文件中查找文件。
My approach is creating the folder in the finder and then dragging it to project.when i need to create a new file in this subfolder is will be added there anyhow.
我的方法是在查找器中创建文件夹,然后将其拖到项目中。当我需要在此子文件夹中创建新文件时,无论如何都会在那里添加。
回答by Henning Hall
- Drag the new files from the finder to the Xcode project file structure.
- Remove the old files.
- 将新文件从 finder 拖到 Xcode 项目文件结构中。
- 删除旧文件。