加载 Storyboard IB 时,Xcode 7.3 非常慢

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36212368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:39:59  来源:igfitidea点击:

Xcode 7.3 is excruciatingly slow when loading Storyboard IB

xcodemacosstoryboard

提问by ChairmanMeowth

I recently upgraded to Xcode 7.3. I found that loading up the storyboard can take anywhere from 5 to 10 minutes to complete(and may sometimes result in a crash). I've restarted my Mac several times. I uninstalled Xcode and reinstalled it to no avail. I then cleared my Derived Data as well as com.apple.dt.Xcode to find that this did not help either. Is anyone experiencing a similar issue and possibly has a solution?

我最近升级到 Xcode 7.3。我发现加载故事板可能需要 5 到 10 分钟才能完成(有时可能会导致崩溃)。我已经多次重新启动我的 Mac。我卸载了Xcode并重新安装它无济于事。然后我清除了我的派生数据以及 com.apple.dt.Xcode,发现这也没有帮助。有没有人遇到类似的问题并且可能有解决方案?

回答by Jeehut

Although this actually might be an issue with incremental changes in Storyboards with Xcode 7.3 you can always speed up build timesby creating multiple small Storyboard files in favor of a big bloated Storyboard.

尽管这实际上可能是使用 Xcode 7.3 对 Storyboards 进行增量更改的问题,但您始终可以通过创建多个小的 Storyboard 文件加快构建时间以支持大的臃肿的 Storyboard

Xcode can then reuse already built Storyboards in subsequent builds (as long as they are not changed) instead of building the complete bloated Storyboard over and over againeven for small changes.

然后 Xcode 可以在后续构建中重用已经构建的 Storyboard(只要它们没有改变),而不是一遍又一遍地构建完整的臃肿的 Storyboard,即使是很小的变化。

Apple even has a guidethat might help getting this started.

Apple 甚至有一个指南可以帮助您开始这项工作。

I hope that helps!

我希望这有帮助!

回答by JPetric

This is really annoying bug/issue with XCode 7.3. So, If you have an hour or so to spend you can download and install XCode 7.3.1 Beta from here https://developer.apple.com/xcode/download/
It seems that this issue has been fixed in this version (at least it works for me).

这对于 XCode 7.3 来说真的是很烦人的错误/问题。所以,如果你有一个小时左右的时间,你可以从这里下载并安装 XCode 7.3.1 Beta https://developer.apple.com/xcode/download/
这个版本似乎已经修复了这个问题(在至少它对我有用)。

Edit: OK. After a few minutes, Interface Builder became extremely slow again. Changing only one property can take up to 15-20 minutes. After some research I have figured out that autolayout constraints were the cause of this issue, BUT only if you have a combination of some components present. I had a segmented control inside a navigation bar. When I removed navigation bar and placed segmented control in a simple UIView, all issues were gone and IB was smooth again.

编辑:好的。几分钟后,Interface Builder 再次变得极其缓慢。仅更改一项属性最多可能需要 15-20 分钟。经过一些研究,我发现自动布局约束是导致此问题的原因,但前提是您存在某些组件的组合。我在导航栏中有一个分段控件。当我移除导航栏并将分段控件放置在一个简单的 UIView 中时,所有问题都消失了,IB 再次变得流畅。

Hope this will help.

希望这会有所帮助。

回答by Ashik

I am using Xcode 7.3.1 and had the same problem. My problem was solved by disabling source control. Go to Xcode->Preferences->Source Controland then Uncheck the Enable Source Control. Worked for me. Thanks.

我正在使用 Xcode 7.3.1 并且遇到了同样的问题。我的问题是通过禁用源代码控制解决的。转到Xcode->Preferences->Source Control,然后取消选中 Enable Source Control。对我来说有效。谢谢。

回答by Raza.najam

Sometimes the storyboard gets slow because of unresolved errors of autolayout. In my case i tested by changing screensizes and it showed me some errors on different sizes. Once i resolved those errors the storyboard was working fine. Please confirm

有时,由于自动布局的未解决错误,故事板会变慢。就我而言,我通过更改屏幕尺寸进行了测试,它显示了不同尺寸的一些错误。一旦我解决了这些错误,故事板就可以正常工作。请确认

回答by Antonio de Perio

Yep I had the same problem. In design mode, it's Autolayout that is causing the 5-10 second delay between edits, especially if it's a large storyboard. Turning off Autolayout in the storyboard at design time fixed the issue for me:

是的,我遇到了同样的问题。在设计模式下,自动布局导致编辑之间有 5-10 秒的延迟,特别是如果它是一个大型故事板。在设计时关闭故事板中的自动布局为我解决了这个问题:

Open project Select storyboard from the Project Navigator Open the file inspector Under Interface Builder Document uncheck 'Use Autolayout'

打开项目从项目导航器中选择故事板打开文件检查器在界面生成器文档下取消选中“使用自动布局”

If you need Autolayout at run time, I recommend you layout your Storyboard in design time with this off (to avoid those long delays between edits) then turn it back on afterwards. Or, turn Auto layout on programatically. Or better yet, split your storyboard out into smaller storyboards.

如果您在运行时需要自动布局,我建议您在设计时布局您的 Storyboard 并关闭此功能(以避免编辑之间的长时间延迟),然后再将其打开。或者,以编程方式打开自动布局。或者更好的是,将您的故事板拆分成更小的故事板。

Referenced this question: Can I disable autolayout for a specific subview at runtime?

参考了这个问题:Can I can disable autolayout for a specific subview at runtime?

回答by Jeff.Lu

I got the same issue recently after I updated the OSX to 10.11. Xcode 7.3 will take almost 5 mintues to respond when I just change the button's font (or anything else change). This made me almost crazy. Incidently, just for a try, I updated Xcode from App Store to 7.3.1. Then I was happy to cry when I opened the storyboard and changed the attributes. Xcode responds smoothly.

我最近在将 OSX 更新到 10.11 后遇到了同样的问题。当我更改按钮的字体(或其他任何更改)时,Xcode 7.3 将需要将近 5 分钟的时间来响应。这让我几乎疯了。顺便说一句,为了尝试,我将 Xcode 从 App Store 更新到 7.3.1。然后当我打开故事板并更改属性时,我高兴地哭了。Xcode 响应流畅。

So please try Xcode 7.3.1 for your problem. Hopefully you can be happy with it.

因此,请尝试使用 Xcode 7.3.1 解决您的问题。希望你能对此感到满意。