如何在自定义 Xcode 项目模板中创建或定义新目标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14651166/
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 create or define a new target in a custom Xcode project template
提问by epologee
TL;DR:What XML snippets do I add to my TemplateInfo.plist files, to create a second compiler target when creating a new Xcode project?
TL;DR:在创建新的 Xcode 项目时,我将哪些 XML 片段添加到我的 TemplateInfo.plist 文件中以创建第二个编译器目标?
While working on my own Xcode project template, I'm trying to have KIF integration testingworking in a 'out of the box' sort of way. KIF requires you to duplicate your regular targetand then modify some properties. This is normally done manually, but it both takes time and leaves a margin for error, while it's so mundane it could be automated.
在处理我自己的 Xcode 项目模板时,我试图让KIF 集成测试以一种“开箱即用”的方式工作。KIF 要求您复制常规目标,然后修改一些属性。这通常是手动完成的,但它既需要时间又会留下错误的余地,虽然它是如此平凡以至于可以自动化。
For clarity, I'm looking to create the second targetin this screenshot automatically:
为清楚起见,我希望在此屏幕截图中自动创建第二个目标:
I got quite far with the whole template customization, but I just can't figure out how to create another target, even though the templates create one for unit testing if you hit that checkbox. How does Apple do that?
我在整个模板自定义方面取得了很大进展,但我无法弄清楚如何创建另一个目标,即使如果您点击该复选框,模板会创建一个用于单元测试的目标。苹果是怎么做到的?
Have a look at the template project over at my github repository. If you want to see what I'm doing with KIF (even though for the answer of this question this is should not be necessary), have a look at the plist in the KIF Integrations.xctemplatefolder.
查看我的 github 存储库中的模板项目。如果您想了解我正在使用 KIF 做什么(即使对于这个问题的答案,这应该不是必需的),请查看KIF Integrations.xctemplate文件夹中的 plist 。
回答by Albert Renshaw
If I understand your question correctly...
如果我正确理解您的问题...
To duplicate the Build Target automatically without manually creating a new one and setting it up select the one you want to duplicate and press CMD+D
要自动复制构建目标而无需手动创建新目标并进行设置,请选择要复制的目标并按 CMD+D
(Instructions on how to do the same things but with (the more likely) build schemes (for future users who wonder to this question) are below:
(有关如何使用(更有可能)构建方案(对于想了解此问题的未来用户)执行相同操作的说明如下:
In xCode click Product (top bar... across from File, Edit, View, etc.) and then at the bottom of the drop-down menu click "New Scheme".
在 xCode 中单击产品(顶部栏...在文件、编辑、查看等对面),然后在下拉菜单底部单击“新建方案”。
To duplicate your scheme (like you suggested) click "Edit Scheme" instead of "New Scheme" then click "Duplicate Scheme"
要复制您的方案(如您建议的那样),请单击“编辑方案”而不是“新方案”,然后单击“复制方案”