在 Xcode 中移动文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6126286/
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
Moving files within Xcode
提问by SuperString
I want to move a file I have in PROJECT/PROJECT.xcodeproj to PROJECT/Classes.
我想将我在 PROJECT/PROJECT.xcodeproj 中的文件移动到 PROJECT/Classes。
The problem with just dragging within Xcode is that Xcode's file hierarchy system is different from the actual system.
只是在 Xcode 中拖动的问题在于 Xcode 的文件层次系统与实际系统不同。
The problem with moving it within Finder/Terminal is that it breaks things and things no longer work.
在 Finder/Terminal 中移动它的问题在于它破坏了东西并且不再起作用。
Please let me know of a solution. Thanks!
请让我知道解决方案。谢谢!
采纳答案by SuperString
heres a solution:
这是一个解决方案:
move the file from your proj to desktop.
将文件从您的项目移动到桌面。
move from desktop back in your proj (select copy resources into folder)
从桌面移回您的项目(选择将资源复制到文件夹中)
回答by mxcl
Works in Xcode 5:
适用于 Xcode 5:
- Move the file in Finder
- Observe that the reference in Xcode turns red
- Open the right panel (
??0
) - Select “Relative to Project” from the Locationpicker.
- Click the folder icon under Location.
- Select the new file location.
- 在 Finder 中移动文件
- 观察Xcode中的引用变成红色
- 打开右侧面板 (
??0
) - 从位置选择器中选择“相对于项目” 。
- 单击Location下的文件夹图标。
- 选择新文件位置。
This allows you to both move files and rename them (both at once if you like).
这允许您移动文件并重命名它们(如果您愿意,可以同时进行)。
Edit: Notably, Xcode 9 supposedly will move files on the filesystem if your group structure mimics the file system.
编辑:值得注意的是,如果您的组结构模仿文件系统,Xcode 9 应该会移动文件系统上的文件。
回答by jules
I have had the same issue. Groups do not represent folders in the file system. I solved my problem by
我有同样的问题。组不代表文件系统中的文件夹。我解决了我的问题
- removing the references from the project
- moving files into the right folders
- add files to the project again. (and do not check the "copy files" option)
- 从项目中删除引用
- 将文件移动到正确的文件夹中
- 再次将文件添加到项目中。(并且不要选中“复制文件”选项)
回答by HumblingJWu
actually, you can just choose to "delete" the files within Xcode. When prompted, select "remove reference" instead of "move to the trash can"
实际上,您可以选择“删除”Xcode 中的文件。出现提示时,选择“删除引用”而不是“移至垃圾箱”
now move the actual files to the location you desire in Finder
现在将实际文件移动到您在 Finder 中想要的位置
Back to Xcode and select "Add file to " after right clicking your project (I have the track pad, so I have the double-finger).
返回 Xcode 并在右键单击您的项目后选择“将文件添加到”(我有触控板,所以我有双指)。
回答by Matthew Frederick
You can move them in a somewhat convoluted way without completely removing and re-adding them this way:
您可以以某种复杂的方式移动它们,而无需以这种方式完全删除和重新添加它们:
回答by Lance Kind
Xcode9 nearlyhandles moving files within Xcode flawlessly. Using Xcode, create a new Group/folder and drag the source files into it. Although Xcode updated the 'build settings' 'compile targets' correctly but when I did a clean build it was still trying to compile using the old locations.
Xcode9几乎可以完美地处理 Xcode 中的移动文件。使用 Xcode,创建一个新的组/文件夹并将源文件拖入其中。尽管 Xcode 正确更新了“构建设置”“编译目标”,但是当我进行干净构建时,它仍在尝试使用旧位置进行编译。
After restarting xCode 9 it worked.
重新启动 xCode 9 后,它工作了。