13

How to change the number of parallel compilations when building a C++ project with XCode ?

I am not talking about distributed builds, but on simultaneous compilations of a set of source files from a single project, on a single computer. (currently using Xcode 3.2.4)

Thanks

dilig0
  • 1,006
  • 2
  • 10
  • 18
  • For information, builds were far too long on my Quad Core. After decreasing this value from 8 to 4, build time became much more reasonnable. – dilig0 Apr 01 '11 at 15:08

5 Answers5

21

For Xcode 4 you must set the IDEBuildOperationMaxNumberOfConcurrentCompileTasks user default, for example:

defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4

Note the "dt". This won't affect xcodebuild on the command line. To do that, use something like

xcodebuild -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=4 ...

(See http://lists.apple.com/archives/xcode-users/2011/Apr/msg00403.html and http://lists.apple.com/archives/xcode-users/2011/Jul//msg00377.html )

Mimika Oh
  • 261
  • 2
  • 3
12

Adjust the PBXNumberOfParallelBuildSubtasks user default, for example:

defaults write com.apple.XCode PBXNumberOfParallelBuildSubtasks 6
一二三
  • 21,059
  • 11
  • 65
  • 74
3

Just for the record - developers at our site using XCode 4 discovered that parallel compilation gets disabled if McAfee anti-virus is installed. Builds that should finish in 15-20 minutes took nearly five hours until McAfee was removed.

J. Peterson
  • 1,996
  • 1
  • 24
  • 21
  • It's probably not that parallel builds are disabled but access is so slow becuase McAfee blocks. I have seen that on Win + OSX also with Avira Antivirus, up to non-writable files because they were locked by the watcher. – Mike Lischke Dec 05 '14 at 15:06
1

For command line builds, I've tested the 2011/Jul mailing list post that Mimika linked, and deployed it on our (Xcode 4.2, on Snow Leopard) build server to save memory like so:

defaults write xcodebuild IDEBuildOperationMaxNumberOfConcurrentCompileTasks 1
rvalue
  • 2,652
  • 1
  • 25
  • 31
  • 2
    After boot, Xcode 6 will use all four of my iMac's processors, but after a while it uses only two. What makes it fall back to two? Does "defaults write xcodebuild IDEBuildOperationMaxNumberOfConcurrentCompileTasks 1" still work in Xcode 6? Thanks. – vonlost Feb 07 '15 at 00:29
0

I don't know why it drops from four to two, but I also found that quitting Xcode 6, then in Terminal entering "defaults write xcodebuild IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4" got me back to four when Xcode is restarted.

vonlost
  • 875
  • 1
  • 7
  • 11