XCode 方案构建目标中的构建顺序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10285964/
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
Build ordering in XCode scheme build targets
提问by Locksleyu
In order to build an installer for my program I added an 'installer' Xcode project/target which copies all the needed binaries to a temporary location and then runs the necessary logic to build the package.
为了为我的程序构建一个安装程序,我添加了一个“安装程序”Xcode 项目/目标,它将所有需要的二进制文件复制到一个临时位置,然后运行必要的逻辑来构建包。
The problem that I am having is I want to map this installer project directly dependent on a few other projects so that they are built (if needed) every time I try to build the installer project.
我遇到的问题是我想映射这个安装程序项目直接依赖于其他几个项目,以便在我每次尝试构建安装程序项目时构建它们(如果需要)。
I added all targets to the installer's Build target list (in the schema) and they are ordered like this:
我将所有目标添加到安装程序的构建目标列表(在架构中),它们的顺序如下:
Project A
Project B
Project C
Installer (self)
However when I do a clean build I see see a build order (in the build log) like this:
但是,当我进行干净的构建时,我看到这样的构建顺序(在构建日志中):
Project C
Installer
Project A
Project B
I need to force a certain build ordering or else the files will not be available for use by the installer. XCode lets you change the order of these items in the UI but the order doesn't seem to do anything. Is there no way to force the build order of dependencies?
我需要强制执行特定的构建顺序,否则安装程序将无法使用这些文件。XCode 允许您更改 UI 中这些项目的顺序,但该顺序似乎没有任何作用。有没有办法强制依赖的构建顺序?
采纳答案by Mark Szymczyk
Make targets A, B, and C target dependencies for the installer target, which will ensure A, B, and C are built before the installer. Select your project file from the project navigator to open the project editor. Select the installer target from the list of targets. Click the Build Phases button at the top of the editor to show the target's build phases. Click the disclosure triangle next to the Target Dependencies build phase. Click the + button to add dependencies.
使目标 A、B 和 C 成为安装程序目标的目标依赖项,这将确保在安装程序之前构建 A、B 和 C。从项目导航器中选择您的项目文件以打开项目编辑器。从目标列表中选择安装程序目标。单击编辑器顶部的 Build Phases 按钮以显示目标的构建阶段。单击 Target Dependencies 构建阶段旁边的显示三角形。单击 + 按钮添加依赖项。
When you add the target dependencies, targets A, B, and C will be built before the installer. If you need A, B, and C to be built in a specific order, you will have to add more target dependencies.
添加目标依赖项时,目标 A、B 和 C 将在安装程序之前构建。如果需要按特定顺序构建 A、B 和 C,则必须添加更多目标依赖项。
回答by yfede
XCode lets you change the order of these items in the UI but the order doesn't seem to do anything.
XCode 允许您更改 UI 中这些项目的顺序,但该顺序似乎没有任何作用。
In my case, this was happening when "Parallelize Build" was ticked in the Scheme "Build" tab.
就我而言,这是在 Scheme“Build”选项卡中勾选“Parallelize Build”时发生的。
After disabling that checkbox, Xcode always followed the order I chose for the targets.
禁用该复选框后,Xcode 始终遵循我为目标选择的顺序。
It makes sense if you think about it: when "Parallelize Build" is enabled, all targets without dependency constraints between them will be built in parallel, which may result in their out-of-order completion.
如果您考虑一下,这很有意义:当启用“Parallelize Build”时,它们之间没有依赖关系约束的所有目标都将并行构建,这可能会导致它们的无序完成。
On the other hand, if you wish their sequentialorder to be strictly followed, well.. that's exactly the contrary of parallelbuilding, and hence you should disable that option.
另一方面,如果您希望严格遵循它们的顺序,那么……这与并行构建完全相反,因此您应该禁用该选项。