xcode 如何将编译源中的文件从一个目标复制并粘贴到另一个目标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8333507/
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 to copy and paste files in Compile Sources from one target to another?
提问by panupan
I have a main target that have certain files included under its target -> Build Phases -> Compile Sources. I'm starting a unit test and would like the unit test to include the same files as the main target. Is there a way to copy and paste the files included in one target to another target?
我有一个主要目标,其目标下包含某些文件-> 构建阶段-> 编译源。我正在开始单元测试,并希望单元测试包含与主要目标相同的文件。有没有办法将一个目标中包含的文件复制并粘贴到另一个目标?
回答by kowal
Yes, you can follow these steps:
是的,您可以按照以下步骤操作:
- Select all Compile Sourceson the main target.
- Right click on the selection and choose Reveal in Project Navigator(
CMD
+Shift
+j
). The files will be selected in the left pane. - Select another target.
- Drag and drop the selected files from Project Navigator to Compile Sourcesof another target.
- 选择主目标上的所有编译源。
- 右键单击选择并选择在项目导航器中显示(
CMD
+Shift
+j
)。将在左窗格中选择文件。 - 选择另一个目标。
- 将选定的文件从项目导航器拖放到另一个目标的编译源。
Xcode 9.2 Update:
Xcode 9.2 更新:
It looks like in Xcode 9.2 you can select only up to 150 itemsat once to use Drag and drop. If you want to copy more items you can do it in batches.
看起来在 Xcode 9.2 中,您一次最多只能选择150 个项目来使用拖放。如果您想复制更多项目,您可以分批进行。
回答by filo
You can edit the PBXSourcesBuildPhase section in your ".pbxproj" file. You cand find the file by looking into your ".xcodeproj" file ( right click the project file + show package contents ). After you find the file look for "PBXSourcesBuildPhase". After you find the collection you can just copy/paste source files from one target to the others.
您可以编辑“.pbxproj”文件中的 PBXSourcesBuildPhase 部分。您可以通过查看“.xcodeproj”文件(右键单击项目文件 + 显示包内容)来找到该文件。找到该文件后,查找“PBXSourcesBuildPhase”。找到集合后,您只需将源文件从一个目标复制/粘贴到其他目标即可。
回答by LearnCocos2D
You can create a duplicate of the target by right-clicking the target and selecting Duplicate. Or press Command+D.
您可以通过右键单击目标并选择复制来创建目标的副本。或按 Command+D。
You can then modify the new target's build settings as needed.
然后,您可以根据需要修改新目标的构建设置。