Compiling development have pain in the ass issues: compiling time. With many mainly Script developer like me, we familiar with edit => refresh => testing => done. But with compiling language like iOS Swift or Android Java/Kotlin, even single bit of change to source code require rebuild (In my knowledge). And it make newbie more stress, panic since you are new and have to make small change step by step to trial and error to see what take effect...
I mean newbie have to make more build
Time compiling >=2 minutes (120s)
Slowest ~5 minutes
- ~500 file source => 50-75s compile
- assets ~500files ~7s
- XIB some take huge time to compile (15-23s); randomly slow each build ie. TagUser..xib some time slow, so it hard to know exactly which xib slow.
- The more file, module included, the more tangled, required messing, So it hard to comment out/ exclude one file. And then total compile time spike up.
1. Almost all Pods libraries already removed:
- Twitter
- Facebook
- Line
- Fabric
- Deploygate ...
And other package like Adobe Creative SDK ...
2. Only GoogleMap, KingFisher and some light (?) package left.
Assets have about 600+ files (already cleaned by Fengniao) but it seem it only take 7s to compile.
3. Excluded about 100-200 file in Utility, some less used module
4. Debug flag
OPTIMIZE_COMPILATION_ALL enabled
5. Ignore signing app
...
All above setup is designed for Debug (Develop) target.
After all optimization, it seem build/compile time still slow. normally it may take 25 to 30s but quite often it spike to 50-60s.
So ~500-700 source files is a thing. In addition 160 xib, storyboard take huge time to build/compile.
Exclude 5 slowest xib not take much effect.
So it seem the culprit lie here: huge number of source files and xib/storyboard.
The only way to reduce compile time seem exclude these file (for only feature/module that u currently work on). Certainly, these file, feature often tangled and required between each other, so we have to modified some script, config.
Some tip on Edit:
Vim is a powerful tool. Both .xcodeproj/project.pbxproj, Source file like Info.plist, Appdelegate ... or event xib/storyboard (with careful). So we have less defend on XCode IDE slow edit.
For example, u can edit Project.xcodeproj/project.pbxproj directly instead of using XCode > Settings > Exclude menu ...
And You can remove file and update xcodeproj/project.pbxproj file later instead of use delete menu on IDE.
And surely, Git is a must have tool to track, store history of change.
The real deal by using vim is that, in many case we can not simple exclude folder because of often we have to required some files inside it. So the only way / simple way is ignore many single file. And using editor instead of GUI XCode is much more efficient.
Log debugging here:
https://stackoverflow.com/questions/40489663/where-xcode-8-places-build-logs
~/Library/Developer/Xcode/DerivedData/... your_project_name-hash
Aha -bash: /usr/bin/du: Argument list too long
May be iTerm2 is a piece of shit.
$du -sh * |grep -v "K\t" # list folder size exclude K sized one. May be need | sort -n
Diving Into Xcode Logs
WebRefs:
https://github.com/fastred/Optimizing-Swift-Build-Times/blob/master/README.md
http://joemburgess.com/2014/10/04/diving-into-xcode-logs/
https://github.com/spotify/XCLogParser
https://www.freecodecamp.org/news/learn-linux-vim-basic-features-19134461ab85/
https://stackoverflow.com/questions/13861658/is-it-possible-to-search-though-all-xcodes-logs
Update 1: 17/12/2019
I found that XCode have export function for analysis log.
And then we can use bash tool like vim, grep for extract information needed.
For example, I want to find all Compiled Swift files in order to know what files have excluded successfully.
$ grep "CompileSwift" xcode-log-17_Dec_19.txt > xcode-swift-log.txt
Remove "CompileSwiftSource" that out of above filter.
You can use reverse grep (grep -v) or vim delete line contain:
:g/keyword/d
Finally, we should sort log-file.txt for easier view.
I mean newbie have to make more build
Time compiling >=2 minutes (120s)
Slowest ~5 minutes
- ~500 file source => 50-75s compile
- assets ~500files ~7s
- XIB some take huge time to compile (15-23s); randomly slow each build ie. TagUser..xib some time slow, so it hard to know exactly which xib slow.
- The more file, module included, the more tangled, required messing, So it hard to comment out/ exclude one file. And then total compile time spike up.
1. Almost all Pods libraries already removed:
- Line
- Fabric
- Deploygate ...
And other package like Adobe Creative SDK ...
2. Only GoogleMap, KingFisher and some light (?) package left.
Assets have about 600+ files (already cleaned by Fengniao) but it seem it only take 7s to compile.
3. Excluded about 100-200 file in Utility, some less used module
4. Debug flag
OPTIMIZE_COMPILATION_ALL enabled
5. Ignore signing app
...
All above setup is designed for Debug (Develop) target.
After all optimization, it seem build/compile time still slow. normally it may take 25 to 30s but quite often it spike to 50-60s.
So ~500-700 source files is a thing. In addition 160 xib, storyboard take huge time to build/compile.
Exclude 5 slowest xib not take much effect.
So it seem the culprit lie here: huge number of source files and xib/storyboard.
The only way to reduce compile time seem exclude these file (for only feature/module that u currently work on). Certainly, these file, feature often tangled and required between each other, so we have to modified some script, config.
Some tip on Edit:
Vim is a powerful tool. Both .xcodeproj/project.pbxproj, Source file like Info.plist, Appdelegate ... or event xib/storyboard (with careful). So we have less defend on XCode IDE slow edit.
For example, u can edit Project.xcodeproj/project.pbxproj directly instead of using XCode > Settings > Exclude menu ...
And You can remove file and update xcodeproj/project.pbxproj file later instead of use delete menu on IDE.
And surely, Git is a must have tool to track, store history of change.
The real deal by using vim is that, in many case we can not simple exclude folder because of often we have to required some files inside it. So the only way / simple way is ignore many single file. And using editor instead of GUI XCode is much more efficient.
Log debugging here:
https://stackoverflow.com/questions/40489663/where-xcode-8-places-build-logs
~/Library/Developer/Xcode/DerivedData/... your_project_name-hash
Aha -bash: /usr/bin/du: Argument list too long
May be iTerm2 is a piece of shit.
$du -sh * |grep -v "K\t" # list folder size exclude K sized one. May be need | sort -n
Diving Into Xcode Logs
WebRefs:
https://github.com/fastred/Optimizing-Swift-Build-Times/blob/master/README.md
http://joemburgess.com/2014/10/04/diving-into-xcode-logs/
https://github.com/spotify/XCLogParser
https://www.freecodecamp.org/news/learn-linux-vim-basic-features-19134461ab85/
https://stackoverflow.com/questions/13861658/is-it-possible-to-search-though-all-xcodes-logs
Update 1: 17/12/2019
I found that XCode have export function for analysis log.
And then we can use bash tool like vim, grep for extract information needed.
For example, I want to find all Compiled Swift files in order to know what files have excluded successfully.
$ grep "CompileSwift" xcode-log-17_Dec_19.txt > xcode-swift-log.txt
Remove "CompileSwiftSource" that out of above filter.
You can use reverse grep (grep -v) or vim delete line contain:
:g/keyword/d
Finally, we should sort log-file.txt for easier view.
Comments
Post a Comment