xcode 目标和项目有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5881048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:57:47  来源:igfitidea点击:

what is the difference between target and project?

iphonecocoa-touchxcodeipadxcode4

提问by GameLoading

here are the images of the project and target

这是项目和目标的图像

what is the difference between this two?

这两者有什么区别?

why both are given? enter image description here

为什么两者都给出? 在此处输入图片说明

An image of project..

项目图..

enter image description hereAn image of target..

在此处输入图片说明目标图像..

回答by Jano

  • A projectis a set of files and general preferences.
  • A targetis a subset of the files, and specific preferences (which override the project preferences).
  • Each target builds a product, which may be a library, executable, or framework.
  • Because a target builds something, it also has Build Phases and Build Rules, where you can add dependencies, and refine what gets copied where and how.
  • 一个项目是一组文件和一般的偏好。
  • 一个目标是文件的一个子集,以及特定的偏好(其覆盖项目偏好)。
  • 每个目标构建一个产品,它可以是库、可执行文件或框架。
  • 因为目标构建了一些东西,它也有构建阶段和构建规则,您可以在其中添加依赖项,并优化在何处和如何复制的内容。

It's a good thing to have both because it lets you create different products from the same set of files. As an example, you can target different architectures/devices, or build a testing product which runs unit tests against your code.

两者兼而有之是一件好事,因为它可以让您从同一组文件创建不同的产品。例如,您可以针对不同的体系结构/设备,或者构建一个测试产品,对您的代码运行单元测试。

回答by Antwan van Houdt

You can have multiple targets in 1 xcode project. That way you can develop a project that has multiple applications or frameworks, like an application that also includes a framework you are working on. You can make xcode compile the framework target, then it can compile the other target, your actual application and copy the framework in the frameworks path in the bundle.

您可以在 1 个 xcode 项目中拥有多个目标。通过这种方式,您可以开发一个具有多个应用程序或框架的项目,就像一个应用程序也包含您正在处理的框架。您可以让 xcode 编译框架目标,然后它可以编译其他目标,即您的实际应用程序,并将框架复制到包中的框架路径中。

回答by allenlinli

  • An projectis a repository for all the files, resources, and information required to build one or more software products.
  • A targetspecifies a product to build and contains the instructions for building the product from a set of files in a project or workspace.
  • 一个项目是为所有的文件,资源,并需要建立一个或多个软件产品信息库。
  • 一个目标指定产品创建并包含在一个项目或工作组一组文件构建产品的说明。

It's well-documented here in Apple official docs - Xcode concepts. I just read it. It could help a lot.

Apple 官方文档 - Xcode 概念中对此进行了详细记录。我刚读完。它可以帮助很多。

回答by Akbar Khan

  • projectis a container for all the files and required resources to build one or more software products. A project contains one or more targets, which specify how to build products. It defines default build settings for all the targets in the project. However, each target can specify its own build settings, thus overriding the default project level settings.
  • A target, on the other hand, specifies a product to build and contains the instructions for building the product from a set of files in a project. A target defines a single product and organizes the inputs into the build system. Projects can contain one or more targets, each of which produces one product.
  • 项目是构建一个或多个软件产品所需的所有文件和资源的容器。一个项目包含一个或多个目标,这些目标指定如何构建产品。它定义了项目中所有目标的默认构建设置。但是,每个目标都可以指定自己的构建设置,从而覆盖默认的项目级别设置。
  • 一个目标,而另一方面,指定产品创建并包含在项目的一组文件构建产品的说明。目标定义单个产品并将输入组织到构建系统中。项目可以包含一个或多个目标,每个目标产生一种产品。