是的,标题是这么说的:-)它们在通俗英语中是什么意思?我真的不明白苹果网站上的解释,我需要重新命名我的目标,恐怕在那之后就什么都不管用了。
目标是通过在Xcode中运行“build”创建的最终产品。它可能是一个应用程序,或一个框架,或静态库,或一个单元测试包。无论它是什么,它通常对应于“已构建产品”文件夹中的单个项目。
方案表示一起工作的目标的集合。它定义了当你在Xcode中选择各种操作(运行、测试、配置文件等)时使用的目标。通常,你只有一个方案,它使用主应用程序目标来运行、存档和配置文件操作,并为测试操作使用一个单元测试目标。如果您正在构建两个相关的应用程序,您可能有两个使用相同单元测试包但不同应用程序目标的方案。
scheme(在Xcode 4中引入)的主要好处是,它们允许你在运行应用程序和单元测试之间切换,而不需要切换所选目标。
我也添加了工作区和项目!
Workspace - Contains one or more projects. These projects usually relate to one another Project - Contains code and resources, etc. (You'll be used to these!) Target - Each project has one or more targets. Each target defines a list of build settings for that project Each target also defines a list of classes, resources, custom scripts etc to include/ use when building. Targets are usually used for different distributions of the same project. For example, my project has two targets, a "normal" build and an "office" build that has extra testing features and may contain several background music tracks and a button to change the track (as it currently does). You'll be used to adding classes and resources to your default target as you add them. You can pick and choose which classes / resources are added to which target. In my example, I have a "DebugHandler" class that is added to my office build If you add tests, this also adds a new target. Scheme - A scheme defines what happens when you press "Build", "Test", "Profile", etc. Usually, each target has at least one scheme You can autocreate schemes for your targets by going to Scheme > Manage Schemes and pressing "Autocreate Schemes Now"
我是一个视觉人,因此我将用一个图表来解释这个概念。
当你有多个目标时,它们可以与Xcode的Run,Test,Profile动作一一匹配,这个概念定义了一个方案
目标是你的项目的一个版本,即。E目标在构建期间使用的类和资源略有不同。对于不同的分发需求,项目可以有多个构建时间设置。
Xcode结构
Workspace
-> Project
-> Target
-> Dependency
-> Scheme
-> Action
-> Build Configuration
-> Build Configuration File(.xcconfig)
工作区(.xcworkspace)——是多个项目的容器。作为跨项目引用的下一步创建[关于]
工作区包含所包含项目的所有方案 工作空间处理所有隐式依赖项
观察:
在同一个工作空间中处理不同的项目并且不捕获是安全的
//if you try to open two projects on two Xcode instances
Couldn't load Project.xcodeproj because it is already opened from another project or workspace
Cocoapods[关于]使用工作区创建Pods项目
Project (.xcodeproj)——它是目标和方案的容器。它定义了代码文件、资源……
项目管理构建配置(由方案更改)和构建配置文件[关于]
您可以将现有项目转换为工作区
File -> Save As Workspace...
[工作空间vs项目]
目标- PBXNativeTarget节。定义一个特定的生成设置集,生成:
应用目标 库和框架目标 测试 总(有关)。例如,它被用来创建一个通用框架或伞形框架
计划
包含操作(运行、测试、配置文件、分析、存档)+配置(附加参数、[构建配置]、诊断)
方案可以共享,这有助于您在CI,迦太基[示例]…和位于:
<project_path>/<project_name>.xcodeproj/xcshareddata/xcschemes
依赖项——目标可以有依赖项。依赖项是针对的源链接。这些依赖关系可以静态或动态链接[关于]它们有两种类型:
显式依赖项[关于]-位于同一项目或嵌套项目中的依赖项的源代码 隐式依赖项[关于]-位于同一工作空间的项目中的依赖项的源代码/封闭代码。
(词汇)
我采用的方法:
目标——较低的抽象——各种构建。每个目标都有自己的构建设置(所以如果你分成几个目标,请为每个目标单独照顾那个巨大的表)。目标有一种包括/排除文件的方便方式,因此您可以在每个文件的基础上有效地配置构建。
Scheme——一种更高的抽象——通过各种部署方式(运行、测试、存档)指导目标。通过环境参数配置构建的方法比较简单,但使用目标中的构建设置。创建/编辑/删除方案比目标更便宜、更容易。
你可以用几种不同的方法来引导一个目标。
tldr;目标包含构建模块/最终产品/应用程序的指令,例如构建watchOS应用程序和iOS应用程序的指令。计划知道如何响应某些操作,例如构建操作或测试操作或存档操作。
请务必查看WWDC16视频- Xcode介绍[45:13]。如果你想获得更深入的知识,那就观看完整的视频。这个视频很简单,但非常基础。我的答案基本上就是这样。
计划
A scheme is how you specify what you want to run and it also contains information about how you want to run it. For example, I could have a project with an iOS app and a Watch app, and in that case, I would have one scheme to run my iOS app and one scheme to run my Watch app Run will run my app in the debugger. Test will run my tests. Profile will run my app in instruments so I can measure its performance. Analyze will run Xcode's static analyzer and help catch problems I might otherwise have missed. And finally, the Archive action will build my app for release and put it in the archive that I can then use to distribute to my testers or to the App Store or to save for future crash log de-symbolication, or symbolication.
项目
A project is a document that you use to organize your code an resources in Xcode. You have references to source code files and resource files on disc, targets which actually build those files into products like your app, Build settings which configure how your targets build their products, and schemes which configure how you perform actions, such as Run, with your targets. Now, to access your project settings, you select your project in the navigator, you select the popover at the top of the editor, and select your project there.
目标
You have references to source code files and resource files on disc, targets which actually build those files into products like your app, Build settings which configure how your targets build their products, and schemes which configure how you perform actions, such as Run [test, build], with your targets. A target contains the instructions to build one thing like an app or a framework. The thing that your target produces is called its product. The set of steps that your target takes to build its product are called build phases. And lastly, a target has Build settings to configure how it builds its product. Now, one thing to note is that both projects and targets have Build settings, and targets inherit the value set at the project level but can override them with a target-specific value. A target's build phases do things like cause dependencies to build first, compile the source files in that target, and link the target against libraries and frameworks.
总结:
目标
帮助将一组文件组合在一起以构建/运行产品/模块/包
通常情况下,它只是你发布到应用商店的产品。 但通常它可以是一个模块,您只需对其运行单元测试。
比如一个应用程序可以有一个iOS目标和一个watchOS目标。或者只是一个iOS Target。或者一个单独的iOS目标和一个测试目标,等等。
如果你转到目标的构建阶段>>编译源,你会看到为目标构建的每个文件。例子:
明确引用苹果文档:
目标指定要构建的产品,并包含从项目或工作区中的一组文件构建产品的说明。目标定义单个产品;它将构建系统所需的输入(源文件和处理这些源文件的指令)组织起来。项目可以包含一个或多个目标,每个目标产生一个产品。
构建产品的说明采用构建设置和构建阶段的形式,你可以在Xcode项目编辑器中查看和编辑。目标继承项目生成设置,但是您可以通过在目标级别指定不同的设置来覆盖任何项目设置。一次只能有一个活动目标;Xcode方案指定活动目标。
A target and the product it creates can be related to another target. If a target requires the output of another target in order to build, the first target is said to depend upon the second. If both targets are in the same workspace, Xcode can discover the dependency, in which case it builds the products in the required order. Such a relationship is referred to as an implicit dependency. You can also specify explicit target dependencies in your build settings, and you can specify that two targets that Xcode might expect to have an implicit dependency are actually not dependent. For example, you might build both a library and an application that links against that library in the same workspace. Xcode can discover this relationship and automatically build the library first. However, if you actually want to link against a version of the library other than the one built in the workspace, you can create an explicit dependency in your build settings, which overrides this implicit dependency.
计划
给定的目标可以通过不同的行动来实现。
构建 运行 测验 配置文件 存档
您可以有一个启用了所有诊断的方案(这会使调试变慢),也可以有一个没有任何诊断的方案。或者运行某些性能相关测试的方案与同时运行单元测试和性能测试的方案。你可以编辑一个方案,让它执行如下动作:
建立多个目标 在任何操作之前或之后执行脚本 在任何行动之前或之后发送邮件 使用内存管理诊断程序运行 为任何操作生成调试或发布版本。
有关更多信息,请参见自定义项目的生成方案
把它们放在一起:
一旦你点击运行,Xcode会查看所选方案。它将找到相关的目标。使用该目标的构建阶段及其构建设置(任何未被目标设置覆盖的项目设置将被包括在内)将产品构建到选定的目的地(目的地可以是iPhone模拟器或物理iPhone或watchOS等)。
再次观看WWDC视频!
推荐文章
- 如何从iPhone应用程序发送邮件
- 架构i386的未定义符号:_OBJC_CLASS_$_SKPSMTPMessage",引用自:错误
- UILabel对齐文本到中心
- Objective-C中方法混合的危险是什么?
- 如何使用接口生成器创建的nib文件加载UIView
- iOS如何设置应用程序图标和启动图像
- 更改UITextField和UITextView光标/插入符颜色
- 'Project Name'是通过优化编译的——步进可能会表现得很奇怪;变量可能不可用
- 如何设置回退按钮文本在Swift
- 模拟器慢动作动画现在打开了吗?
- 如何为TableView创建NSIndexPath
- 滑动删除和“更多”按钮(就像iOS 7的邮件应用程序)
- 使UINavigationBar透明
- 如何改变推和弹出动画在一个基于导航的应用程序
- 删除/重置核心数据中的所有条目?