是否可以使用 distcc 来构建 iPhone 设备版本?
据我所知,当我将任何项目从模拟器切换到设备构建配置时,构建不再是分布式的,而是本地构建的。
那么,让 Xcode 使用分布式构建机制进行设备构建是否有什么魔力呢?有人对此有明确的说法,甚至有一些实践经验吗?
除非您了解分布式构建和 Xcode 主题,否则请不要投票或关闭。这不是一个关于签名分发的新手问题。
As far as I can tell, the moment I switch any of my projects from Simulator to Device build configuration, the build is no longer distributed, but built locally.
So, is there any kind of magic involved in getting Xcode to use the distributed building mechanism for device builds? Anyone have a definite word on this or even some hands-on experience?
Please do not downvote or close unless you understand the topic of distributed builds and Xcode. This is not a noobie question about signing for distribution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们还发现 Xcode 3.2.5 不分发设备版本,而模拟器版本则通过 distcc 正确分发,尽管在 Xcode Preferences -> 下设置了所有必要的选项。分布式构建。
但是,可以解决 Xcode 的限制并强制它也分发设备版本。这看起来像是苹果公司的一个疏忽(错误!),他们没有默认启用设备分布式构建。
您需要执行的步骤如下:
增加 Xcode 用户默认值PBXNumberOfParallelBuildSubtasks。这限制了并行构建任务的最大数量,并默认为 CPU 核心的数量(有关详细信息,请参阅 Apple 自己的 Xcode 用户默认参考文档)。我将其从 2 增加到 16,如下:
写入 com.apple.Xcode PBXNumberOfParallelBuildSubtasks 16
或对于 Xcode 4.2
defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 16
请务必重新启动 Xcode 以使上述更改生效。
您需要设置自己的 DISTCC_HOSTS 环境变量值,如
distcc
手册页中详细说明。为此,您需要在自己的
/Developer/usr/bin/distcc
脚本中设置 DISTCC_HOSTS(然后调用原始/Developer/usr/bin/distcc
二进制文件,您将其重命名为其他名称)。请注意,Xcode 会为每个编译单元调用/Developer/usr/bin/distcc
并在每次调用之前设置 DISTCC_HOSTS,因此您需要使用此伪装脚本来覆盖 Xcode。我自己的
distcc
脚本如下(我将原始distcc
二进制文件重命名为distcc.orig
):<前><代码>#!/bin/sh
export DISTCC_HOSTS="--随机化您的主机列表,每个主机后跟 ',cpp,lzo'"
/Developer/usr/bin/distcc.orig“$@”
退出$?
在 DISTCC_HOSTS 中有很多可以调整的选项,特别是使用您自己的本地主机来进行一些编译而不是把所有内容都外包出去,但上面的内容至少应该让您开始。最适合您的方式显然取决于您自己的 Mac 硬件和网络性能。
根据我自己的经验,在相对较慢的网络上使用由几个四核 Mac 和我自己的双核 Mac 组成的分布式构建服务器设置,可以将整个设备重新构建时间从大约 15 分钟减少到大约 5 分钟。
We have also found that Xcode 3.2.5 does not distribute Device builds, whereas Simulator builds are distributed properly with distcc, despite setting all necessary options under Xcode Preferences -> Distributed Builds.
However, it is possible to workaround Xcode's limitation and force it to also distribute Device builds. It looks like an oversight (bug!) on Apple's part that they have not enabled Device distributed builds by default.
The steps you need to take are as follows:
Increase the value of the Xcode user default PBXNumberOfParallelBuildSubtasks. This limits the maximum number of parallel build tasks and defaults to the number of CPU cores (see Apple's own Xcode User Default Reference document for details). I increased it from 2 to 16, as follows:
write com.apple.Xcode PBXNumberOfParallelBuildSubtasks 16
or for Xcode 4.2
defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 16
Be sure to re-start Xcode for the above change to take effect.
You'll need to set your own value of the DISTCC_HOSTS environment variable as detailed in
distcc
man page.To do this, you'll need to set DISTCC_HOSTS from within your own
/Developer/usr/bin/distcc
script (which then calls the original/Developer/usr/bin/distcc
binary, which you rename to something else). Note that Xcode calls/Developer/usr/bin/distcc
for each compilation unit and sets DISTCC_HOSTS before each call, hence you need to use this masquerade script to override Xcode.My own
distcc
script is simply as follows (and I renamed the originaldistcc
binary todistcc.orig
):There are plenty of options to tweak in DISTCC_HOSTS, particularly concerning using your own localhost to also do some of the compilation instead of farming everything out, but the above should at least get you started. What works best for you will obviously depend on your own Mac hardware and network performance.
In my own experience, using a distributed build server setup comprised of a couple of quad-core Macs together with my own dual-core Mac on a relatively slow network reduced the full Device re-build time down from about 15 minutes to about 5.
实际上,我编写了一个工具来管理网络上的机器组以进行分发构建。它支持设置
PBXNumberOfParallelBuildSubtasks
设置(XCode 3.x + 4.x 之间有所不同)。它也可以在不需要安装 XCode 的构建支持机器的情况下工作。我这样做的部分原因是我们使用 XCode 获得的分布式构建速度非常糟糕。去年我们一直在工作中使用它,大约有 50-100 个可用 CPU 用于并发 Android/iOS/桌面构建,速度非常棒!这是 SourceForge 站点:http://sourceforge.net/projects/distccmanager。我设想它允许跨平台编译支持(即 windows + mac 机器帮助 android 构建)。
欢迎任何贡献!
I actually wrote a tool to manage groups of machines on a network for distributing builds. It includes support for setting the
PBXNumberOfParallelBuildSubtasks
setting (different between XCode 3.x + 4.x). It also works w/o build support machines having to install XCode. I did it partially due to the terrible distributed build speeds we were getting with XCode. We've been using it at work for the last year with ~50-100 available CPUs for concurrent android/iOS/Desktop builds and the speed is awesome! Here's the SourceForge site: http://sourceforge.net/projects/distccmanager.I envisioned it to allow cross platform compilation support (i.e windows + mac machines helping with android builds).
Any contributions are welcome!
当我意识到上一个问题因不是真正的问题而被关闭时,我正要将其标记为重复。
我没有使用 distcc 的经验,但我知道可能是什么问题。与模拟器构建不同,设备构建需要签名。我想问题可能是签名只能在本地进行,或者 XCode 拒绝签署远程构建的任何内容。
另一种可能性是您仅针对模拟器构建而不是设备构建进行了 distcc 配置。
I was just about to mark this as a duplicate when I realized that the previous question was closed for not being a real question.
I have no experience with distcc, but I have an idea of what might be the problem. Device builds need to be signed as opposed to simulator builds. I guess the problem might be that the signing can only happen locally or that XCode refuses to sign anything that has been built remotely.
Another possibility is that you did the distcc configuration only for simulator builds and not device builds.