XCode 8非常慢的快速编译 [英] XCode 8 very slow swift compiling

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

问题描述

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

Ever since Swift 3 and XCode8 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. 转到 Project 选择目标

  2. 构建设置 - > Swift编译器 - 自定义标志

  3. 添加到其他Swift标志 -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)

之后,警告应显示如下:

after that a warning should displayed as follow:


Getter'frameDescription'花了108ms进行类型检查(限制:50ms)

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

然后你知道该怎么做;)

and after that you know what to do ;)

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

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