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
Looks like this configuration is not enough.
I tried various methods to speed up the compile time:
- Set to
Код: Выделить всё
HEADERMAP_USES_VFS(no change)Код: Выделить всё
YES
- Set to
Код: Выделить всё
Build Settings / Architectures / Build Active Architecture Only(some improvement)Код: Выделить всё
YES
-
Set (8)
Код: Выделить всё
defaults write com.apple.Xcode PBXNumberOfParallelBuildSubtasks 4
(sometimes it's become even worse) -
Set optimisation level to (no major improvement)
Код: Выделить всё
-Onone
- Set debug information format - instead of
Код: Выделить всё
DWARFКод: Выделить всё
DWARF with dSYM File
- Disable from your scheme (no major
Код: Выделить всё
Find implicit dependencies
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 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
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
Does anyone have any solution on improving compile time for Swift?
Источник: https://stackoverflow.com/questions/415 ... ation-time
Мобильная версия