2

I experienced much slower compilation of the swift unit test files after migrating the project from Xcode 6.2 to 6.3.1.

My unit test use Quick/Nimble framework. Also in each test file I have:

import MyApp

The interesting thing is that when I comment out that import, the compilation is lightning fast. I tested it out on some dummy unit test files, that in fact don't use any of my application's code. But that import makes huge difference for the compilation time.

I didn't observe that big impact when using Xcode 6 - 6.2. Do you have any ideas how to improve the compilation speed now?

Marcin
  • 1,823
  • 3
  • 16
  • 18

3 Answers3

2

According to one of the replies in http://devforums.apple.com/message/1128702#1128702 . Enabling Whole Module Optimization in Build Settings makes the issue walked around.

WeZZard
  • 3,536
  • 1
  • 23
  • 26
  • but then we lose the advantages of the incremental builds, that means that instead of having a first build taking 20 minutes and following builds taking 10, every build will take 15 minutes – Vik Apr 24 '15 at 06:06
  • @Vik but in my case, it takes the same time to how it took in Xcode 6.2 with Whole Module Optimization disabled – WeZZard Apr 28 '15 at 01:36
0

Obviously this would involve seeing your code but try to not use so many concatenations for your strings and strongly type your vars.

You can see which file is taking a long time to compile by watching the build process in Xcode file by file. It's the last tab, touch the running build process and you'll see each file as it's being compiled.

Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42
  • The slow compilation affects each unit test file (like SomeClassTests.swift) which is importing the main app module. – Marcin Apr 22 '15 at 14:43
  • all the files are taking around 7 seconds each, and our project has around 20k lines of Swift code, where every single file is on average 100 lines of code – Vik Apr 22 '15 at 14:44
  • 1
    we don't do a lot of string concatenation (or any, even), and we don't strongly type our vars. But even then, the app target takes about a minute to compile (after the first build), while the test target always takes more than 15 minutes (kloc is about the same as the app target) – Vik Apr 22 '15 at 14:45
  • Without seeing the code in that test it's tough to narrow it down. Is the test target compile slow if you simply remove everything other than the import MyApp? Unfortunately it's a trial an error scenario to track it down. – Mark McCorkle Apr 22 '15 at 15:37
0

Apple released Xcode 6.3.2 on 18th May (yesterday) which seems to cite slow compile times. Does the update fix your issue?

PeteSE4
  • 309
  • 1
  • 4
  • 21