Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improving build time on XCode 4.5 for a huge game project

Scenario: We have an XCode project for an iOS game which has about 7000+ files.

Only 1000+ files are code. Rest of them are images, sounds, level data, XIBs, plists, config files etc.

Its a universal app so, we have separate set of resources for old iPhone, retina iPhone, iPad etc. We also have PNG and PVRTC for few things like BG images etc to make the best use of different hardware.

Problem:

Right now the project takes about

42 seconds to Clean (Cmd - Shift - K)

8.3 minutes for a full rebuild (Cmd - B) (While rebuilding, half of the progress bar fills in 1 min)

aaaand... 5 mins 36 for just running (Cmd - R) ??

After that, I pressed "Stop" and clicked on "Run" again without doing absolutely anything else. and it took 2 mins 40 secs to just "Run again"

I also saw resources getting copied again, some files getting built again as shown by XCode above the progress bar.

Any solutions to reduce time in any of these phases is highly appreciated. Please ?

P.S. The project was started during the XCode 3 days, and we have been automatically updating the xcodeproj file each time a new XCode comes out.

like image 417
Rajavanya Subramaniyan Avatar asked Jan 16 '13 10:01

Rajavanya Subramaniyan


People also ask

Why does Xcode build take so long?

Xcode projects composed of multiple targets, one target may be dependent on another target to build. When one target is depending on another target to build then it creates dependency. Building the targets serially will take time and may not be good for utilizing system resources.

What is parallelize build Xcode?

First it's good to understand what "Parallelize Build" does. Source: This option allows Xcode to speed up total build time by building targets that do not depend on each other at the same time. This is a time-saver on projects with many smaller dependencies that can easily be run in parallel.


2 Answers

What you are looking for is improving your compile and launch time for debug, right? So what about creating a different target for every platform? So you keep the same code but only package a subset of resources for debug purpose depending on your debug device.

To do this, go on your actual target, right click and duplicate. Keep your actual target untouched, it's the fat one! For the new target, let's say it's iPad retina, go to "build phases" -> "copy bundle resources" and remove all the resources which are not related to iPad Retina. Do the same for every platform.

Then on top left of Xcode, select the good target for the specific device. Maybe, you can define which device is accepted for a target.

If you use continuous integration, let your build machine compile the fat target at night.

like image 120
Geraud.ch Avatar answered Sep 19 '22 05:09

Geraud.ch


It is not possible to solve a problem if the cause for the problem is unknown. "My car does not start any longer, is there a way to make it start again?"; most likely, but only if the reason why it currently refuses start is known. It sounds a bit like you hope that there is a magic switch in Xcode named "Build fast" and by enabling it, everything becomes much faster. If there was such a switch, don't you think it would be enabled by default? Don't you think it would actually always be enabled?

I also wonder why you tagged this question with "compiler" and "compiler-optimization". According to your own statement, compiling takes only one minute out of 8.3 minutes build time, so how would further reducing compile time make the overall process much faster? Even if compile time was cut down to zero, this would still leave you with 7.3 minutes build time. Don't optimize at the wrong end.

It's like optimizing code. If your code is too slow, all optimizations are pointless if you don't where in your code most of your time is spent. Optimizing a piece of code to run ten times faster will do nothing for overall performance if only 0.1% of all time is spent in that piece of code. The first step of code optimization is profiling code and finding out how much time is spent at what piece of code.

So to make your build process faster, the first and most important step is finding out why exactly the build times are slow right now. Without that knowledge, all answers people could give here are just guessing into the blue. Once you know exactly where the problem is, you can come back and ask precisely how to make this one step faster. You start by optimizing the slowest step, then the second slowest, and so on.

Take a look at the build log in Xcode

enter image description here

Make sure to select "All Messages", otherwise you will only see warnings and errors, or only errors. Now start a clean build, select the new log that pops up to the left and keep monitoring this log. You will exactly see when Xcode is starting an operation and when it approaches to the next operation. That should give you a first impression which of the tasks take rather long to complete. And once you told us which tasks those are, we can start making suggestion how you might possibly be able to make this task somewhat faster.

like image 31
Mecki Avatar answered Sep 21 '22 05:09

Mecki