[英]What targets should I be adding my files to in my xcode project
I'm working on an xcode app using swift and xcode 8.1. 我正在使用swift和xcode 8.1开发xcode应用程序。 I keep adding files such as pictures and .plist files to my main folder with my storyboard, but each time it asks what targets I want to add it to. 我一直使用情节提要向我的主文件夹中添加图片和.plist等文件,但是每次它询问要添加到的目标时。 Should I be adding it to my test targets as well? 我也应该将其添加到我的测试目标中吗? If so, why? 如果是这样,为什么? Whats the rule to know what targets to add it to. 有什么规则知道要添加到哪个目标。
No , you shouldn't add your files to the test target. 不 ,您不应该将文件添加到测试目标。 Unit test target has access to your application files anyway. 单元测试目标仍然可以访问您的应用程序文件。
According to the Apple documentation , target is a single build artifact. 根据Apple 文档 ,目标是单个构建工件。 Because of that, you should only add the files which are building blocks of a specific target. 因此,您只应添加构成特定目标的构建块的文件。
A target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace. 目标指定要构建的产品,并包含根据项目或工作空间中的一组文件构建产品的说明。 A target defines a single product; 目标定义单个产品; it organizes the inputs into the build system—the source files and instructions for processing those source files—required to build that product. 它将输入组织到构建系统中,即构建该产品所需的源文件和处理这些源文件的说明。 Projects can contain one or more targets, each of which produces one product. 项目可以包含一个或多个目标,每个目标产生一个产品。
For the most basic scenario with one application target and two test targets the general rule is as follows 对于具有一个应用程序目标和两个测试目标的最基本方案,一般规则如下
In more complex scenarios you can have more targets in your application. 在更复杂的场景中,您的应用程序中可以有更多目标。 You can have iMessage extension, share extension etc. You can also have multiple targets for building variants of the same applications but the general rule stays the same. 您可以具有iMessage扩展名,共享扩展名等。也可以具有多个目标来构建同一应用程序的变体,但一般规则保持不变。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.