简体   繁体   中英

What is target in iPhone development and why would I need different targets?

iPhone开发的目标是什么?为什么我需要不同的目标?

Different targets would allow you to build multiple apps within a single project, maybe by selecting different combinations of source files or image files, maybe with different app names or bundle ID's (using different plists), maybe with different compiler defines (for use by #ifdef's inside your source code files to disable code), etc.

A typical use would be to use 2 targets in 1 project to build 2 apps, one for the Paid version and one for the Free Lite version, with some key feature #ifdef's out in the Lite version, and with a slightly different name and icon. You could also use 2 targets to build an iPhone and an iPad version of an app by using slightly different Build Settings and including different .xib files in each target.

A target is the product of a build. For instance, a product may produce a static library, or an application. It is the end result of the build process.

Depending on the application, you may have many targets. One for your application, another for your test code, etc. Multiple targets are part of daily life in many, many projects.

A target allows you to specify different ways to build your project. Each build target has multiple phases, for example: Copy Headers, Compile Sources, Link with Libraries and Run Scripts. This allows you to build different versions of your project, or have different build steps.

Some examples of how this can be useful:

  • A full build which builds libraries, applications, with an installer and documentation.
  • A debug build which just builds enough for you to debug one library.
  • A Unit Test build which build the code and automatically runs the unit tests.

When you set up a target, in addition to setting what steps that happen during the build, you can also specify the environment that the build happens in. To see what all the options are, right-click on one of your targets and select Get Info. This brings up a dialog with all the options and switches for the build.

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