每次击键后 Xcode 都会继续构建故事板 [英] Xcode keeps building storyboard after each keystroke

查看:19
本文介绍了每次击键后 Xcode 都会继续构建故事板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用故事板的 Xcode 项目最近进入了一种非常奇怪的状态:Xcode 一直在构建整个项目,尤其是在 每次按键之后构建故事板.我没有发现这种行为的原因,无论是在我的项目中区分所有有趣的文件(故事板和项目)还是 Xcode 中的设置(也许我只是找不到它?)不用说,这个功能"使我的项目几乎不可能工作因为当我输入新代码时,CPU 一直在忙于重建故事板.有人看到了吗?

My Xcode project using a storyboard entered in a very weird state recently: Xcode keeps building the whole project and notably the storyboard after each keypress. I found no reason for this behavior neither in my project diffing all interesting files (storyboard and project) neither a setting in Xcode (maybe I just could not find it?) Needless to say that this "feature" makes working on my project nearly impossible since the CPU is constantly occupying with rebuilding the storyboard when I type new code. Anybody seen this?

推荐答案

它是由源头文件中的 IB_DESIGNABLE 定义引起的.可能只有当包含 IB_DESIGNABLE 的头文件包含(甚至隐式)到您当前正在编辑的源文件中时,它才会出现问题.

It is caused by the IB_DESIGNABLE definitions in the source header files. Probably it makes problem only if the header file containing IB_DESIGNABLE is included (even implicitly) to the source file you are currently editing.

我没有找到如何禁用 IB_DESIGNABLE 从而连续编译故事板和源文件的最终解决方案.我很感激 Xcode 标志来暂时禁用它.我还尝试使用 #ifdef 宏包围 IB_DESIGNABLE 但即使 #ifdef 评估为 false,它们也会被考虑.将 IB_DESIGNABLE 一一注释掉会有所帮助,但它不是包含许多 IB_DESIGNABLE 的可行解决方案.

I did not find a definitive solution how to disable IB_DESIGNABLE and thus compiling the storyboard and the source files continuously. I would appreciate an Xcode flag to disable this temporarily. I tried also surrounding the IB_DESIGNABLE with #ifdef macros but they are considered even if the #ifdef evaluates to false. Commenting out one by one the IB_DESIGNABLE helps but it is not a feasible solution with many IB_DESIGNABLEs.

更新

我终于找到了一种避免这种烦人行为的快速方法.在活动窗口中打开故事板后,从编辑器菜单中禁用自动刷新视图".这将停止更新故事板编辑器中使用您的自定义代码的视图,从而显着加快您的开发速度.当您再次需要即时编译以对自定义代码进行可视化预览时,请再次启用此选项(似乎您还必须重新打开故事板以使其再次运行).

I finally found a quick way to avoid this annoying behavior. Having the storyboard opened in the active window, disable "Automatically Refresh Views" from the Editor menu. This will stop updating the views in the storyboard editor that use your custom code and thus speed up your development significantly. When you need again the just-in-time compiling to have a visual preview of your custom code, enable this option again (it seems you also have to re-open your storyboard to make it working again).

您可能希望向命令添加键绑定,例如 command-option-control-A,以轻松打开/关闭行为.要在 Xcode 中添加按键绑定,请在首选项中触摸命令逗号,选择按键绑定选项卡,使用搜索栏查找命令,然后双击右侧区域以添加所需的按键.

You may wish to add a key binding to the command, such as command-option-control-A, to easily toggle the behavior on/off. To add a key binding in Xcode, touch command-comma for preferences, choose the Key Bindings tab, use the search bar to find the command, then double-click on the right area to add your desired keystroke.

放弃"方法

或者关闭自动刷新视图",并且永远不要打开它.

Alternately turn "Automatically Refresh Views" off, and never turn it on.

刷新所有视图"方便地击键,例如 command-option-shift-R

Make a convenient keystroke for "Refresh all views", say command-option-shift-R

在您工作时,只需不时或根据需要触摸 command-option-shift-R.通常只需要在处理情节提要时触摸 command-option-shift-R.

As you work, just touch command-option-shift-R from time to time, or as needed. It's generally only necessary to touch command-option-shift-R as you work on the storyboard.

这篇关于每次击键后 Xcode 都会继续构建故事板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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