what is the difference between target and project?

2019-03-11 03:47发布

问题:

here are the images of the project and target

what is the difference between this two?

why both are given?

An image of project..

An image of target..

回答1:

  • A project is a set of files and general preferences.
  • A target is 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.



回答2:

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.



回答3:

  • An project is a repository for all the files, resources, and information required to build one or more software products.
  • 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.

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



回答4:

  • project is 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.