Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile large source files (10k+ lines) in Xcode 4.x

I've got some source files ranging from 20,000 lines up to 120,000 lines each. They are made of simple (very long) functions, just a long series of calls to C methods (in Apple's API's - e.g. Quartz) and should be easy to compile.

However, Xcode takes hours to compile them, and it FORCES a re-compile seemingly every time the xcodeproj file changes (xcode bug?). Also, doing an Archive (for upload to App Store) causes a complete re-compile anyway.

These files are stupid-long - they're the output of a code-generating tool - and I may eventually be able to get them smaller - but surely there's a way to make clang work properly on files this length?

Things I've tried:

  1. Run in 32bit mode - IMPOSSIBLE: Apple has now removed this feature https://stackoverflow.com/a/9791396/153422
  2. Add more CPU / cores - NEGLIGIBLE EFFECT: clang is single-threaded on most operations
  3. Add more RAM - NEGLIGIBLE EFFECT: 8 GB RAM was not noticeably better than 2 GB RAM (no surprise: it's only one file - very unlikely it's going to use up gigs of memory!)
  4. Add an SSD drive - SMALL EFFECT: laptop with slightly slower CPU + SSD compiles slightly faster (10%?) than desktop with slightly faster CPU + normal HD
  5. Disable SVG/GIT integration - NO EFFECT: Apple's implementation of SVN is so buggy that we have it turned off already - for ALL projects.
  6. Disable OS X indexing - SMALL EFFECT: Apple's Spotlight / background indexing is broken in lots of ways. Turning it off made build times a little faster - but maybe because it makes Xcode faster generally.
like image 540
Adam Avatar asked Mar 24 '26 05:03

Adam


1 Answers

Possible approach:

  • Convert your project to use makefiles by using pbxbuild
  • Call gmake with the option -j [n] (try for a good n)

Advantages:

  • No xcodeproj file changes
  • Utilization of paralle compiling
like image 145
Matthias Avatar answered Mar 25 '26 18:03

Matthias