Xcode keeps building storyboard after each keystroke
Asked Answered
S

2

147

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?

Schliemann answered 12/2, 2015 at 11:14 Comment(0)
S
428

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.

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.

Update

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

enter image description here

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.

"Leave it off" approach

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

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

enter image description here

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.

Schliemann answered 13/2, 2015 at 13:38 Comment(21)
Not sure how it got turned on, but turning off "Automatically Refresh Views" solved my problemVasiliki
It's frustrating. It keeps building project event after I Turned off "Automatically Refresh Views". Mine is Xcode 7. I have 5 storyboards. And Only 1 is opened in other tab.Stockholm
I’m on Xcode 7.2 and this solution solved my problem.Livvie
Xcode 7.3 is constantly building project when active editor has storyboard opened. Luckily this answer solved my problem. Apple keeps impressing me...Materials
On Xcode 7.3, I remarked out the IBDesignable attributes, compiled, and it started working. I then un-remarked the IBDesignable, and it continued working properly!Anting
This doesn't happen only with Storyboards, I was having the same problem with XIBs.Ladoga
freaking finally... my xcode 8.1 kept building and building and building... works with 8.2 beta as well. but the long building process itself hasnt been solved. at allHolms
This would have to be one of the best answers on the whole site. Sending a bounty to say thanks! I added an image showing the menu choice. Thanks a million @MrTJ, you rockQuipster
thanks, my pleasure to help. also great work improving the answer!Schliemann
@Schliemann I can't seem to find the "Automatically refresh Views" in Editor on xcode 8.2.1Wipe
@Wipe make sure to have an IB document (xib or storyboard) opened when you try itSchliemann
@Wipe well I think the whole point of Playgrounds is that they are continuously compiled as you enter code :)Schliemann
Xcode Version 8.2.1 (8C1002) problem solved. When I found this answer and it solve my problem, I couldn't stop my tears. I spent 2 days in nightmare deleting derived data, cleaning project, reinstalling all pods. ( I think it is time for apple, give all development of IDE to Jetbrains. What apple do it is just a shit! Thank you!Staghound
Thank you so much! I was getting this issue even in Xcode 8.3. Just disabled "Automatically refresh Views" and restarted my Xcode. Now it's fine.Austronesia
Thanks a lot, xcode keeps building really makes me feel upset.Cathepsin
This solution works on Xcode 9 too. Turn of "Automatically Refresh Views" in Storyboard, and no more constant re-building. Thank you so much!Chally
Thank you, I was running circles to fix this problem. It's shocking that in Xcode 9 it rebuilds everything even if you change a space in a comment.Preterite
Thank you so much for this. It doesn't make storyboard on Xcode 9 magically fast but it helps a bit.Fibrinolysin
OMG! This was completely doing my head in. I do have the IB_DESIGNABLES in play. Quite why Xcode has to continually re-build, like every other minute and cause the environment to free-fall into editor-performance-hell, is quite beyond me. So, great. This teensy-teensy setting has helped.Enceladus
Xcode 11.4 here. Some things have come to stay. 🤷‍Kerge
6 years passed, I don't work with iOS since years, but people keep thanking me for this answer... maybe it's time for Apple to rethink the UX of Xcode..?Schliemann
H
7

I had this problem and the accepted answer did not work for me.

The problem I had was that I always keep the storyboard open in it's own tab within XCode so that I can access it quickly.

The only way I could fix it was to either close that tab or select a different file (like a normal code file) and then close and reopen XCode. Thereafter it was no longer rebuilding on each keystroke.

Be warned however if you need to open the storyboard to make changes then this problem can sometimes reappear and I will have to repeat the above process.

Can't wait till Apple fixes this as it is very frustrating indeed!

(ノಠ益ಠ)ノ彡┻━┻

Hummocky answered 27/9, 2017 at 12:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.