John W808
John W808

Reputation: 53

Xcode rebuilding constantly after implementing a class

I recently used this "iOS Color Picker" (the top response) from StackOverflow into my project. It's absolutely fantastic, and draws straight into Interface Builder - however, it also seems to cause Xcode to rebuild constantly.

As soon as I type one single character, Xcode rebuilds the entire project and it's getting incredibly tedious. All the information I could find on the matter tells me to turn off "Live Issues" under the Xcode prefs - but as a relative beginner to coding, I rely heavily on being able to see errors as they appear.

My question is: is there any way to turn off this constant rebuilding WITHOUT disabling "live issues"? (either by altering the iOS Color Picker code, or some other option in Xcode itself?)

Thanks!

Upvotes: 3

Views: 358

Answers (1)

Satish Babariya
Satish Babariya

Reputation: 3096

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.

Upvotes: 1

Related Questions