简体   繁体   English

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

[英]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 对于具有一个应用程序目标和两个测试目标的最基本方案,一般规则如下

  • Add application classes to the application target. 将应用程序类添加到应用程序目标。
  • Add unit test case classes to the unit tests target. 将单元测试用例类添加到单元测试目标。
  • Add UI test classes to the ui tests target. 将UI测试类添加到ui测试目标。

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.

相关问题 为什么我的Xcode知道项目的目录应该有文件? - Why my Xcode know the project's directory should have the files? 在上传到github之前,我应该隐藏iOS Xcode项目中的哪些文件? - Which files in my iOS Xcode project should I hide before uploading to github? 将Dlib添加到我的Xcode项目中,但未找到.h文件 - Adding Dlib to my Xcode project but no .h files are found 我应该在新的Xcode项目中使用autolayout吗? - Should I use autolayout in my new Xcode project? 为什么不能从XCode项目中删除文件? - Why can't I delete files from my XCode project? Xcode-如果我为图像文件创建了一个组并且它们不在项目的基础上,可以吗? - Xcode - is it ok if I made a group for my image files and they are not at the base of the project? 在Xcode中将源代码管理添加到我的项目中 - Adding source control to my project in xcode 在 Xcode 中为目标添加通用和特定的可本地化文件 - Adding general and specific localizable files for targets in Xcode 我在我的 ios 项目中添加了一些文件,但它们没有显示在 XCode 项目导航器中 [XCode 13.2] - I added some files in my ios project but they are not showing up in XCode project navigator [ XCode 13.2 ] iOS,我应该在项目中设置架构设置? - iOS, what should I set architectures setting in my project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM