我应该将我的文件添加到我的 xcode 项目中的哪些目标
What targets should I be adding my files to in my xcode project
我正在使用 swift 和 xcode 8.1 开发 xcode 应用程序。
我一直在使用故事板将图片和 .plist 文件等文件添加到我的主文件夹中,但每次它都会询问我要将其添加到哪些目标。我是否也应该将它添加到我的测试目标中?如果是这样,为什么?知道将其添加到哪些目标的规则是什么。
否,您不应将文件添加到测试目标。无论如何,单元测试目标都可以访问您的应用程序文件。
根据 Apple documentation,目标是单个 build 工件。因此,您应该只添加作为特定目标的构建块的文件。ui。
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 扩展、共享扩展等。您还可以拥有多个目标,用于构建相同应用程序的变体ui,但一般规则保持不变。
我正在使用 swift 和 xcode 8.1 开发 xcode 应用程序。 我一直在使用故事板将图片和 .plist 文件等文件添加到我的主文件夹中,但每次它都会询问我要将其添加到哪些目标。我是否也应该将它添加到我的测试目标中?如果是这样,为什么?知道将其添加到哪些目标的规则是什么。
否,您不应将文件添加到测试目标。无论如何,单元测试目标都可以访问您的应用程序文件。
根据 Apple documentation,目标是单个 build 工件。因此,您应该只添加作为特定目标的构建块的文件。ui。
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 扩展、共享扩展等。您还可以拥有多个目标,用于构建相同应用程序的变体ui,但一般规则保持不变。