workspace, project, target, sche

2018-04-25  本文已影响55人  mengjz

workspace, project, target, scheme 解析

workspace

A workspace is an Xcode document that groups projects and other documents so you can work on them together. A workspace can contain any number of Xcode projects, plus any other files you want to include. In addition to organizing all the files in each Xcode project, a workspace provides implicit and explicit relationships among the included projects and their targets.

workspace 是最大的集合,其可以包含多个 projet,同时可以管理不同的 project 之间的关系。workspace 是以 xcworkspace 的文件形式存在的。(这点和 project 一致)

workspace 的存在是为了解决原来仅有 project 的时候不同的 project 之间的引用和调用困难的问题。

个人感觉 workspace 用的最多的地方就是 pod install改造过的项目,不同的 project 就是一个个的组件,workspace 把他们组装在一起,project 相互之间独立又有联系。(有的 project 之间可能会有依赖关系)

同时,一个 workspace 的 project 们共用一个编译路径。

project

An Xcode project is a repository for all the files, resources, and information required to build one or more software products. A project contains all the elements used to build your products and maintains the relationships between those elements. It contains one or more targets, which specify how to build products. A project defines default build settings for all the targets in the project (each target can also specify its own build settings, which override the project build settings)

scheme

在 project 的最后这么写着

You use Xcode schemes to specify which target, build configuration, and executable configuration is active at a given time.

同时对 scheme 的定义是:

An Xcode scheme defines a collection of targets to build, a configuration to use when building, and a collection of tests to execute.

也就是说,scheme 是用来决定运行哪个 target 的(不止这个功能,注意后面还有描述),同时,target 既可以存储在 project 中,也可以存储在 workspace 中,一般就是一个 scheme 对应着一个 target。

这个界面就是设置,可以针对编译,运行,单元测试,动态分析,静态代码分析以及打包进行一些配置。

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.

也就是说,target 决定了如何编译文件(workspce 中或者 project 中),他给编译系统提供输入。虽然 project 中也会有一些编译选项,不过 target 中的如果和 project 中的不同就会覆盖。其主要影响的是 build setting 以及 build phases

build setting主要是一些编译选项:

而在 build phases则是要编译的文件,依赖的 target 类似这样的信息:

实际使用中我们可以用前者决定某个版本的 product 是 dubug 还是 release 什么的。后者可以用来决定用 project 中的不同文件、库什么的。

上一篇下一篇

猜你喜欢

热点阅读