Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use distcc for building iPhone device builds?

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.

like image 729
Steven Kramer Avatar asked May 27 '11 11:05

Steven Kramer


1 Answers

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 original distcc binary to distcc.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.

like image 155
webkai Avatar answered Nov 15 '22 22:11

webkai