我应该什么时候检查 Xcode 方案的“Parallelize Build”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33023433/
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-15 08:01:03  来源:igfitidea点击:

When should I check "Parallelize Build" for an Xcode scheme?

xcodecompilationparallel-processing

提问by meisel

I see that this option is unchecked in my current scheme and that a few places around the web recommend against it in certain cases. Can someone give a more thorough method of determining when this option can be checked for a scheme?

我看到我当前的方案中未选中此选项,并且网络上的一些地方在某些情况下建议不要使用它。有人可以提供更彻底的方法来确定何时可以检查此选项的方案吗?

回答by kgaidis

I don't know the internals of the "Parallelize Build" setting, but we can deduct why the setting might not be beneficial sometimes.

我不知道“Parallelize Build”设置的内部结构,但我们可以推断为什么设置有时可能没有好处。

First it's good to understand what "Parallelize Build" does. Source:

首先,最好了解“并行构建”的作用。来源

This option allows Xcode to speed up total build time by building targets that do not depend on each other at the same time. This is a time-saver on projects with many smaller dependencies that can easily be run in parallel.

此选项允许 Xcode 通过同时构建互不依赖的目标来加快总构建时间。对于具有许多可以轻松并行运行的较小依赖项的项目,这可以节省时间。

When you have many targets that inter-depend on other targets this option can produce problems.

当您有许多相互依赖于其他目标的目标时,此选项可能会产生问题。

For example, imagine that one target is a framework, that your application target depends on. If you made modifications to the framework target, then there are cases where you MUST build the framework target BEFORE the application target. Parallelizing these won't work because for the application target and framework target to work nice together, they must be "in sync." We can't build the application target, without compiling the changes in the framework target first.

例如,假设一个目标是一个框架,您的应用程序目标依赖于该框架。如果您对框架目标进行了修改,那么在某些情况下,您必须在应用程序目标之前构建框架目标。将这些并行化是行不通的,因为要使应用程序目标和框架目标良好地协同工作,它们必须“同步”。如果不首先编译框架目标中的更改,我们就无法构建应用程序目标。

The above is a simple example, one that Xcode might handle nicely already, but some projects get very complex and without feeding proper information of your target-dependencies to Xcode, it might not be able to correctly parallelize your targets.

上面是一个简单的例子,Xcode 可能已经很好地处理了这个例子,但是有些项目变得非常复杂,如果没有将目标依赖项的正确信息提供给 Xcode,它可能无法正确并行化您的目标。

In summary, the setting is likely beneficial, and can reduce build speeds If you enable the setting and don't see any problems with the code being out-of-sync across targets. Otherwise, turn it off. As with all performance settings, make sure to test and measure whether you actually are seeing build speed increases.

总之,该设置可能是有益的,并且可以降低构建速度如果您启用该设置并且没有发现代码跨目标不同步的任何问题。否则,将其关闭。与所有性能设置一样,请确保测试和衡量您是否真的看到构建速度提高。