Xcode 组和文件:如何将文件从项目 A 复制到项目 B 而不发疯?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/910132/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:34:25  来源:igfitidea点击:

Xcode Groups & Files: How can I copy files from project A into project B without getting crazy?

iphonexcode

提问by Thanks

For some reason, the representation in Xcode "Groups & Files" does not match the file hierarchy in the folder where all my real project files are. And for some reason, I can't copy a entire group or even single file and put that into another project. So I have a nice hierarchy of images within "Groups & Files", but all thos ordered images are unordered like a big mess in just one giant folder full of stuff on my file system. Really horrible ;)

出于某种原因,Xcode“组和文件”中的表示与我所有真实项目文件所在文件夹中的文件层次结构不匹配。出于某种原因,我无法复制整个组甚至单个文件并将其放入另一个项目中。所以我在“组和文件”中有一个很好的图像层次结构,但是所有有序的图像都是无序的,就像在我的文件系统上一个装满东西的巨大文件夹中一样乱七八糟。真的很可怕;)

So now I wanted to put all my icons into another project, but I cant just copy the Group "img > gui > icons". I have to pick every single icon image from my file system, where icons are mixed up with a few hundred other images and files.

所以现在我想把我所有的图标放到另一个项目中,但我不能只复制组“img > gui > icons”。我必须从我的文件系统中挑选每一个图标图像,其中图标与数百个其他图像和文件混合在一起。

Is there some hidden option I can activate so that Xcode will manage to reproduce the hierarchy of "Groups & Files" inside my project folder on the file system? Or how else could I copy those files?

是否有一些我可以激活的隐藏选项,以便 Xcode 能够在文件系统上的项目文件夹中重现“组和文件”的层次结构?或者我还能如何复制这些文件?

回答by cdespinosa

It's not really possible to transplant a Groups hierarchy intact from one project to another. Some suggested approaches:

将 Groups 层次结构完整地从一个项目移植到另一个项目是不可能的。一些建议的方法:

  • If the files you want to bring across are the vast majority of the project, just clone the project and delete everything that's not the files you want to copy.
  • If it's a lot of files in a small number of groups, then set up the groups in the new project, and drag-copy the files from the old project groups into the new project groups
  • Write an AppleScript to move the hierarchy across with a recursive-descent algorithm
  • ◆◆ Open both project.pbxproj files as text files, and carefully copy the File References and Group References from one to another.
  • 如果您想要传递的文件占项目的绝大部分,只需克隆项目并删除所有不是您想要复制的文件的内容。
  • 如果文件数量少,分组多,则在新项目中设置分组,将旧项目组中的文件拖拽复制到新项目组中
  • 编写 AppleScript 以使用递归下降算法移动层次结构
  • ◆◆ 将两个project.pbxproj 文件作为文本文件打开,并小心地将文件引用和组引用从一个复制到另一个。

回答by Alex Reynolds

Copy icon files in a filtered-Finder window to an "icon-only" folder. Then import them into your new Xcode project. Repeat for any other categories.

将过滤后的 Finder 窗口中的图标文件复制到“仅图标”文件夹。然后将它们导入到新的 Xcode 项目中。对任何其他类别重复此操作。

回答by theprojectabot

Steps: 1.Open up the group in Xcode 2.Select all the items you want to have in your other project 3. Right click and show in finder. 4. Copy those files to a new folder in Finder 5. Now drag and drop those files in the new folder in Finder to your newly created group folder in Xcode on the new project. 6. Accept the copy instructions on 'add file' action in Xcode

步骤: 1. 在 Xcode 中打开组 2. 选择您想要在其他项目中拥有的所有项目 3. 右键单击​​并在 finder 中显示。4. 将这些文件复制到 Finder 中的新文件夹中 5. 现在将这些文件在 Finder 中的新文件夹中拖放到新项目上 Xcode 中新创建的组文件夹中。6. 接受 Xcode 中“添加文件”操作的复制说明

回答by IlDan

Have a look to this other question here

看看这个问题,其他在这里

回答by Lawrence Johnston

See my previous question here.

在这里查看我之前的问题。

Also, file a bug with Apple to let them know you'd like the option to have groups represent the folder structure on disk.

此外,向 Apple 提交错误,让他们知道您希望选择让组代表磁盘上的文件夹结构。

回答by Reconquistador

I am late, but this is a possibility:

我迟到了,但这是一种可能性:

Open the directory of your project using Finder. Copy whole directory (in Xcode its used as a group) into your new project. In Project navigator, right click and press "Add Files". In dialog box, select copied directory and its done.

使用 Finder 打开项目目录。将整个目录(在 Xcode 中用作一个组)复制到您的新项目中。在项目导航器中,右键单击并按“添加文件”。在对话框中,选择复制的目录并完成。