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 distr开发者_如何学Goibuted builds and Xcode. This is not a noobie question about signing for distribution.
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.2defaults 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
):#!/bin/sh export DISTCC_HOSTS="--randomize your list of hosts, each followed by ',cpp,lzo'" /Developer/usr/bin/distcc.orig "$@" exit $?
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.
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!
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.
精彩评论