我正在使用 swift 和 xcode 8.1 开发 xcode 应用程序。 我不断将图片和 .plist 文件等文件添加到 Storyboard的主文件夹中,但每次它都会询问我要将其添加到哪些目标。我是否也应该将其添加到我的测试目标中?如果是这样,为什么?知道将其添加到哪些目标的规则是什么。
最佳答案
否,您不应将文件添加到测试目标。无论如何,单元测试目标都可以访问您的应用程序文件。
根据苹果documentation ,目标是单个构建工件。因此,您应该只添加作为特定目标构建 block 的文件。
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.
对于具有一个应用程序目标和两个测试目标的最基本场景,一般规则如下
- 将应用程序类添加到应用程序目标。
- 将单元测试用例类添加到单元测试目标。
- 将 UI 测试类添加到 ui 测试目标。
在更复杂的场景中,您的应用程序中可以有更多目标。您可以拥有 iMessage 扩展、共享扩展等。您还可以拥有多个目标来构建相同应用程序的变体,但一般规则保持不变。
关于ios - 我应该将文件添加到 xcode 项目中的哪些目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46866998/