理解 xCode 方案
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12606057/
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
understanding xCode schemes
提问by user387184
From the docs it says about schemes:
从文档中它说到方案:
"An Xcode scheme defines a collection of targets to build, a configuration to use when building, and a collection of tests to execute."
“Xcode 方案定义了要构建的目标集合、构建时要使用的配置以及要执行的测试集合。”
So I thought I create one debug scheme and one release scheme and set the build settings for Project and targets accordingly, ie using the distribution profiles for release scheme and the develop profile for debug.
所以我想我创建了一个调试方案和一个发布方案,并相应地设置项目和目标的构建设置,即使用发布方案的分发配置文件和调试的开发配置文件。
But these settings DO NOT change when I select different schemes. In fact when I set the code signing to distribution it remains - switching to different schemes does not change anything.
但是当我选择不同的方案时,这些设置不会改变。事实上,当我将代码签名设置为分发时,它仍然存在 - 切换到不同的方案不会改变任何东西。
Many thanks for clarifying!
非常感谢您的澄清!
回答by Mark Szymczyk
You're confusing build configurations and schemes. Xcode projects have two build configurations: Debug and Release. In the build settings editor, you can give build settings different values for the Debug and Release build configurations. Click the disclosure triangle next to a build setting to show the values for the Debug and Release configurations. In your example you would find the Code Signing Identity build setting in the build settings editor. Set the value of the Code Signing Identity build setting to your develop profile for the Debug build configuration, and set it to the distribution profile for the Release build configuration.
您混淆了构建配置和方案。Xcode 项目有两种构建配置:调试和发布。在构建设置编辑器中,您可以为调试和发布构建配置赋予不同的构建设置值。单击构建设置旁边的显示三角形以显示调试和发布配置的值。在您的示例中,您会在构建设置编辑器中找到代码签名标识构建设置。将代码签名标识构建设置的值设置为调试构建配置的开发配置文件,并将其设置为发布构建配置的分发配置文件。
After setting the build settings for the Debug and Release build configurations, use the scheme editor to choose the build configuration to use. The scheme editor has the following actions where you can choose the build configuration: Run, Test, Profile, Analyze, and Archive. Xcode initially uses the Debug configuration for running, testing, and analyzing and uses the Release configuration for profiling and archiving. The Run action is the one you're most likely to change over the course of developing your app.
在为 Debug 和 Release 构建配置设置构建设置后,使用方案编辑器选择要使用的构建配置。方案编辑器具有以下操作,您可以在其中选择构建配置:运行、测试、分析、分析和存档。Xcode 最初使用 Debug 配置来运行、测试和分析,并使用 Release 配置进行分析和归档。Run 操作是您在开发应用程序的过程中最有可能更改的操作。
In most cases you can get away with one scheme. You don't normally need one Debug scheme and one Release scheme. The main reason you would need one Debug and one Release scheme is if you needed to run, test, profile, and analyze your app for both the Debug and Release build configurations.
在大多数情况下,您可以使用一种方案。您通常不需要一种 Debug 方案和一种 Release 方案。您需要一个 Debug 和一个 Release 方案的主要原因是,如果您需要针对 Debug 和 Release 构建配置运行、测试、剖析和分析您的应用程序。
回答by Pat Niemeyer
Contrary to the accepted answer above in Xcode 7 (at least) schemes definitely do maintain their own debug and release settings. You can maintain separate debug and release "schemes" and use them to switch quickly between the two builds using the shortcut control-command-left/right bracket (previous / next scheme).
与上面在 Xcode 7 中接受的答案相反(至少)方案肯定会维护自己的调试和发布设置。您可以维护单独的调试和发布“方案”,并使用它们使用快捷键 control-command-left/right 括号(上一个/下一个方案)在两个构建之间快速切换。
The advantage of this is being able to quickly jump back and forth between a release and a debug build when doing finicky performance testing. Release builds with optimizations turned on take forever and mess with the stack traces, etc.
这样做的好处是能够在进行挑剔的性能测试时在发布和调试版本之间快速来回切换。启用优化的发布构建需要永远并且弄乱堆栈跟踪等。