Xcode 8 非常慢的 Swift 编译 [英] Xcode 8 very slow Swift compiling

查看:22
本文介绍了Xcode 8 非常慢的 Swift 编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从 Swift 3 和 Xcode 8 以来,我的项目编译速度非常慢.每次我向文件添加一个空行时,重新编译需要整整一分钟.当我检查输出时,没有需要很长时间的特定文件.(我也用这个工具来衡量它:https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode)

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)

它似乎总是一次编译 4 个文件.节奏"相当稳定.只是很慢...

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..

这不是根本问题的解决方案,但我花了一些时间将更多代码移至框架.这产生了不同(仅仅是因为它每次必须重新编译更少的文件).这不应该是必要的,但它变得无法忍受......我当然仍在寻找合适的解决方案.

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.

推荐答案

这个问题的一个问题是我们不知道错误的初始化/声明在哪里.我的同事建议的一个解决方案是找出哪个函数需要很长时间才能编译:

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. 转到项目选择你的目标
  2. 构建设置 -> Swift Compiler - 自定义标志
  3. 添加到Other Swift Flags -Xfrontend -warn-long-function-bodies=50(50代表时间以毫秒为单位)
  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)

之后应显示如下警告:

Getter 'frameDescription' 耗时 108 毫秒进行类型检查(限制:50 毫秒)

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

然后你知道该怎么做;)

and after that you know what to do ;)

这篇关于Xcode 8 非常慢的 Swift 编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆