Xcode:项目和目标,将资源添加到目标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16992070/
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: Project and Target, add resources to target?
提问by MichiZH
I'm building my first app and I'm a bit confused about all the project and target settings. So far I understand that a project can have multiple targets, for example a lite and a full version. So first I'm building my full version and later on adjusting it for the lite one.
我正在构建我的第一个应用程序,但我对所有项目和目标设置都有些困惑。到目前为止,我知道一个项目可以有多个目标,例如精简版和完整版。所以首先我正在构建我的完整版本,然后针对精简版进行调整。
My question is now about the resources you add to the targets. So far I've never checked the checkbox "Add to target …" while adding images, fonts etc. Still it works fine. So why or why shouldn't I check this box? And if I need to check it, how can I do this for all the images etc. I've added to the project?
我现在的问题是关于您添加到目标的资源。到目前为止,我从未在添加图像、字体等时选中“添加到目标...”复选框。仍然可以正常工作。那么为什么或为什么我不应该选中这个框?如果我需要检查它,我如何为所有图像等执行此操作。我已添加到项目中?
And I think in my resource folder are still some resources I don't need anymore and actually deleted in Xcode (correctly, not just deleting the link basically)..how can I get rid of them?
而且我认为在我的资源文件夹中仍然有一些我不再需要的资源实际上在 Xcode 中被删除了(正确的,不仅仅是基本上删除链接)..我怎样才能摆脱它们?
回答by rakmoh
When you add a file/resource in Xcode (either using "New File" or "Add File to "), you will see a checkbox for all the targets in your project. You can check the ones that you want to include the new file/resource. For the existing file/resources in xcode, you have following two options:
当您在 Xcode 中添加文件/资源时(使用“新建文件”或“将文件添加到”),您将看到项目中所有目标的复选框。您可以检查要包含新文件/资源的那些。对于 xcode 中现有的文件/资源,您有以下两个选项:
- For your target->Build Phases->Copy Bundle Resources, you can add resources to the target.
- Click on the file/resource in project navigator, under "Utility View"->Target Membership, you can select/deselect the targets that need to include/remove this file/resource.
- 对于您的目标->构建阶段->复制捆绑资源,您可以向目标添加资源。
- 在项目导航器中点击文件/资源,在“Utility View”->Target Membership 下,可以选择/取消选择需要包含/删除此文件/资源的目标。
Regarding deleting resources, when you delete a resource or any file in XCode, it will give you options: "Remove Reference" or "Move to Trash". For both of these options, resource will be removed from all the targets and XCode project file. However, if you choose "Move to Trash" it will also be removed from the folder in your hard disk.
关于删除资源,当您在 XCode 中删除资源或任何文件时,它会给您选项:“删除引用”或“移至垃圾箱”。对于这两个选项,资源将从所有目标和 XCode 项目文件中删除。但是,如果您选择“移至废纸篓”,它也会从硬盘中的文件夹中删除。