ios - 我应该将文件添加到 xcode 项目中的哪些目标

标签 ios xcode project-structure

我正在使用 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/

相关文章:

ios - 接收方在 self.performSegue(withIdentifier, sender) 中没有带有标识符的 segue

ios - UIPageViewController 错误中的导航栏

ios - 在 objective-c 模块中使用 swift 时无法构建 Objective-C 模块

ios - 在 swift 项目中与 xmppframework 一起使用时出现 cocoalumberjack 问题

asp.net-mvc - 带有 EF、存储库、实体的清洁解决方案(项目)结构

ios - Swift Share 扩展,ALAsset 为 nil

ios - 如何向 GET 请求添加 header 字段和参数?

xcode - 有什么方法可以使用 ios 应用程序的 xcode 远程访问 postgresql 吗?

Android Studio 未在项目结构中显示模块