Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

ios - Xcode 8 very slow Swift compiling

Ever since Swift 3 and Xcode 8 my project compiles quite slowly. Every time I add so much as an empty line to a file, recompiling takes a full minute. When I check the output, there is no particular file that takes very long. (I also used this tool to measure it: https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode)

It always appears to compile 4 files at once. The "rythm" is quite steady. Just very slow...

Also: Whenever I open or switch between files, it can take very long till I get autocomplete, or errors/warnings.

What things can I check? I almost feel like there is some flag I set that just drags down the build speed like crazy..

EDIT: This is not a solution to the underlying problem, but I spent some time on moving more code to frameworks. This made a difference (simply because it has to recompile less files every time). This shouldn't be necessary but it got unbearable... I'm of course still looking very much for a proper solution.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A issue with this problem is that we don't know where is the wrong initialization/declaration . A solution that my colleague suggest is to find which function take long time to compile so:

  1. Go to Project select your target
  2. Build Settings -> Swift Compiler - Custom Flags
  3. Add to Other Swift Flags -Xfrontend -warn-long-function-bodies=50 (50 represent the time in milliseconds)

after that a warning should displayed as follow:

Getter 'frameDescription' took 108ms to type-check (limit: 50ms)

and after that you know what to do ;)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...