简体   繁体   English

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

[英]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. 不同的目标将允许您在一个项目中构建多个应用程序,可能是通过选择源文件或图像文件的不同组合,可能具有不同的应用程序名称或包ID(使用不同的plists),可能具有不同的编译器定义(供#使用)。 ifdef位于您的源代码文件中以禁用代码),等等。

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. 典型的用途是在一个项目中使用2个目标来构建2个应用程序,一个用于付费版本,一个用于免费精简版,其中一些关键功能#ifdef在精简版中提供,并且名称和图标略有不同。 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. 您还可以使用2个目标来构建iPhone和iPad版本的应用程序,方法是使用稍有不同的“构建设置”,并在每个目标中包含不同的.xib文件。

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. 这会弹出一个对话框,其中包含所有选项和构建选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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