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?
2 Answers
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_DESIGNABLE
s.
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).
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
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.
-
10Not sure how it got turned on, but turning off "Automatically Refresh Views" solved my problem – MandisaW Jul 06 '15 at 20:21
-
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. – arjavlad Sep 25 '15 at 12:49
-
I’m on Xcode 7.2 and this solution solved my problem. – Vakas Mar 11 '16 at 06:12
-
1Xcode 7.3 is constantly building project when active editor has storyboard opened. Luckily this answer solved my problem. Apple keeps impressing me... – Oleksii Taran Apr 01 '16 at 05:35
-
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! – leanne Apr 29 '16 at 17:23
-
This doesn't happen only with Storyboards, I was having the same problem with XIBs. – Dielson Sales Jul 06 '16 at 18:57
-
1freaking 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 all – David Seek Nov 28 '16 at 22:45
-
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 rock** – Fattie Jan 22 '17 at 15:45
-
thanks, my pleasure to help. also great work improving the answer! – MrTJ Jan 23 '17 at 08:47
-
@MrTJ I can't seem to find the "Automatically refresh Views" in Editor on xcode 8.2.1 – Arshak Feb 14 '17 at 07:35
-
@Arshak make sure to have an IB document (xib or storyboard) opened when you try it – MrTJ Feb 14 '17 at 09:31
-
1@Arshak well I think the whole point of Playgrounds is that they are continuously compiled as you enter code :) – MrTJ Feb 14 '17 at 14:05
-
24Xcode 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! – korgx9 Feb 24 '17 at 05:41
-
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. – Anurag Sharma Apr 17 '17 at 05:23
-
2Thanks a lot, xcode keeps building really makes me feel upset. – Chauyan Aug 21 '17 at 00:57
-
8This solution works on Xcode 9 too. Turn of "Automatically Refresh Views" in Storyboard, and no more constant re-building. Thank you so much! – P.L. Sep 22 '17 at 04:03
-
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. – andreamazz Oct 16 '17 at 08:36
-
Thank you so much for this. It doesn't make storyboard on Xcode 9 magically fast but it helps a bit. – Joshua Vidamo Apr 06 '18 at 08:34
-
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. – Carl Hine Oct 31 '18 at 16:30
-
Xcode 11.4 here. Some things have come to stay. – RyuX51 Mar 26 '20 at 12:59
-
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..? – MrTJ Feb 17 '21 at 14:08
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!
(ノಠ益ಠ)ノ彡┻━┻

- 1,187
- 11
- 27