3

My swift project is becoming unusable because of huge compiling time.

I'm on XCode 6.4, the project counts around 50 files plus a realm database and around 10 pods (alamofire, locksmith, SwiftyJSON, Facebook,...)

It takes around 20min to compile it from scratch. Adding a simple line takes at least 5min to compile and i realized that it recompiles ALL files even for one line of changes.

I'm sure it's not supposed to be like that.

What actions should i do to improve that ? What is the common parameters to have a fast build? How can i avoid all the files to be recompile for one single change?

I already tried common optimization parameters, like the ones suggested here : Why is Swift compile time so slow? but nothing helped me so far.

UPDATE

xctool run result (xctool -workspace MyApp.xcworkspace -scheme MyScheme -jobs 1 build) :

  • The app itself : 3730559ms (around 1h)
  • The overall total (including pods and all) : 4662682ms (1h17min)

A single file takes between 20sec to 60sec on average

I need to test on another more powerful host, but anyway, smth is definitely wrong, and it didn't take that long a few days ago

Community
  • 1
  • 1
Sylver
  • 2,285
  • 3
  • 29
  • 40
  • In my experience the slow down is usually due to small subset of files and to very few lines of code inside them that somehow confuse the compiler. Reformulating those lines may fix the problem. Did you try the approach suggested [here](http://stackoverflow.com/a/31614385/4934077) in order to find out which files are taking longer than others to compile? – Mario Zannone Jul 31 '15 at 08:08
  • Yeah, i read a lot about such problems. I just used xctool to have a better insight of the problem. Each file took between 40 to 60s. Moreover, a simple modification (like adding a `println()`) will trigger a full rebuild of all files, which should not happen even with files confusing the compiler, right? – Sylver Jul 31 '15 at 17:45
  • I've witnessed two main reasons for slow compilations: 1. too much type inference, 2. big literal dictionaries or arrays declarations in code. On a specific project after refactoring these two things it cut the compile time by 90%. There's probably other reasons that I don't know of, but just in case it could help... – Eric Aya Jul 31 '15 at 18:59
  • Thanks Eric. I already read about these reasons. I think i could improve some declarations for the reason 1. but i don't have such things as in 2. I'm wondering if such well known problems affect only the files they're in or that could be a reason for xcode to recompile all files, modified or not? – Sylver Aug 03 '15 at 21:04

0 Answers0