简体   繁体   English

Xcode:项目和目标,将资源添加到目标?

[英]Xcode: Project and Target, add resources to target?

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 中删除了(正确的,不仅仅是基本上删除链接)..我怎样才能摆脱它们?

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.当您在 Xcode 中添加文件/资源​​时(使用“新建文件”或“将文件添加到”),您将看到项目中所有目标的复选框。 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 中现有的文件/资源​​,您有以下两个选项:

  • 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".关于删除资源,当您在 XCode 中删除资源或任何文件时,它会给您选项:“删除引用”或“移至垃圾箱”。 For both of these options, resource will be removed from all the targets and XCode project file.对于这两个选项,资源将从所有目标和 XCode 项目文件中删除。 However, if you choose "Move to Trash" it will also be removed from the folder in your hard disk.但是,如果您选择“移至废纸篓”,它也会从硬盘中的文件夹中删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM