Xcode 针对不同目标的不同资源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1023371/
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
Xcode Different Resources For Different Targets
提问by FlorianZ
I am developing an iPhone app and there will be a Full as well as a Lite version of that app. In order get both bundles from the same source code and Xcode project I added another target to the Xcode project.
我正在开发一个 iPhone 应用程序,该应用程序将有完整版和精简版。为了从相同的源代码和 Xcode 项目中获得两个包,我向 Xcode 项目添加了另一个目标。
Now, I want to have the Lite target copy only a subset of the resource files to the bundle. But, Xcode won't simply let me delete individual files from the "Copy Files to Bundle" build step, since I imported all my resources as folder references. I need this in order to maintain a directory structure in the resources directory.
现在,我想让 Lite 目标只将资源文件的一个子集复制到包中。但是,Xcode 不会简单地让我从“将文件复制到捆绑包”构建步骤中删除单个文件,因为我将所有资源作为文件夹引用导入。我需要这个来维护资源目录中的目录结构。
How do I solve this problem? Any suggestions or ideas are greatly appreciated!
我该如何解决这个问题?非常感谢任何建议或想法!
回答by Kris Jenkins
In the left-hand panel of Xcode, right-click on the "Groups & Files" bar at the top. Check "Target Membership".
在 Xcode 的左侧面板中,右键单击顶部的“组和文件”栏。勾选“目标会员”。
Now you'll see a tick against every file that should be included in your current build target. Untick the ones you don't want, switch to your other target, and repeat.
现在,您将看到应包含在当前构建目标中的每个文件的勾号。取消你不想要的那些,切换到你的另一个目标,然后重复。
回答by RickDT
Instead of manipulating the "Copy Bundle Resources" step of your target, you can right-click resource files or groups (folders), choose "Get Info," and selectively leave stuff out of your Lite build under the Targets tabs of the info window for the file(s) you selected. Doing this on a group (folder) recurses the changes, so using resource groups (folders) is a nice easy way to make separate resources collections for separate builds.
您可以右键单击资源文件或组(文件夹),选择“获取信息”,然后在信息窗口的“目标”选项卡下有选择地将内容从 Lite 版本中删除,而不是操作目标的“复制捆绑资源”步骤对于您选择的文件。在组(文件夹)上执行此操作会递归更改,因此使用资源组(文件夹)是为单独的构建制作单独的资源集合的一种很好的简单方法。