I have a problem with Swift compile time.
Configuration:
- MacBook Pro (Retina, 13-inch, Mid 2014)
- 2,6 GHz Intel Core i5
- 8 GB 1600 MHz DDR3
- SSD 256 (up to 800 MB/s)
- 1k classes
- 10 pods
Compile time: 3 min.
Looks like this configuration is not enough.
I tried various methods to speed up the compile time:
- Set
HEADERMAP_USES_VFS
toYES
(no change)
- Set
Build Settings / Architectures / Build Active Architecture Only
toYES
(some improvement)
Set
defaults write com.apple.Xcode PBXNumberOfParallelBuildSubtasks 4
(8) (sometimes it's become even worse)Set optimisation level to
-Onone
(no major improvement)
- Set debug information format -
DWARF
instead ofDWARF with dSYM File
- Disable
Find implicit dependencies
from your scheme (no major improvement)
Created a new project and moved all files to the new one (takes too long and give small time improvement)
Change compilator from default to others available (even worse)
Strict rules on how to write fast compiled Swift code (below more details)
I've found a few posts where people describe the same problem: here and here
I guess everyone is waiting for new Xcode 8.2 beta 2 where:
Xcode will not rebuild an entire target when only small changes have occurred. (28892475)
But this is only partially true, I still have long compile time - moved from 6-12 minutes to 3-8. Detailed description of this can be found here and here
Also, I followed all these rules during code writing:
- Chained function reduction
- Unwrapping the optionals
- Implicit typing for an object (dictionary especially)
- Avoiding ?? operator (this one extremely hungry!!)
- Avoiding ?: operator
In othe words, don't use any "new cool features" because you'll wait for ages.
One more try - is a workaround described here:
Go to Product -> Scheme -> Edit Scheme. Select Build in left side column and uncheck "Find implicit dependencies" But this flag should remain checked when you are building the project for the first time.
But, this workaround isn't what I'm looking for and this is also can be as a temporary solution.
Swift is a pain not because it's hard to write, but because it's hard to use (at least on some machines).
For comparison: I have a project on Objective-C with 2k classes, and 11 pods - clean compile time is ~30 seconds.
Also I found a lot of opened bugs on Swift performance:
- SR-2461
- SR-1465
- SR-1707
- SR-663
- and many others, the list is too long, and some of them were opened a few years ago
My question is: