简体   繁体   中英

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. 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. 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM