Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IBDesignable view causes endless rebuilding

Tags:

I'm writing a UIView subclass that uses both IBInspectable and IBDesignable. I'm not doing anything unusual, but my subclass causes Xcode 6.2 to endlessly rebuild the project. My Identity Inspector shows this state oscillation under the heading 'Designables':

'Designables' state oscillating between 'Updating' and 'Up to date'

Every time the build restarts, the inspector loses focus. This makes it hard to edit anything from IB, which defeats the purpose of writing this class in the first place.

Here is the implementation of my DesignableTestView:

import UIKit
@IBDesignable class DesignableTestView: UIView {

    @IBInspectable var testBackground:UIColor? {
        didSet {
            if testBackground != nil {
                self.backgroundColor = testBackground
            }
        }
    }
}

Is there any way to change my code or settings of Xcode to prevent the constant rebuilding?

like image 374
BradB Avatar asked Mar 25 '15 15:03

BradB


2 Answers

I'm wonder if this designable view class is part of the current target. In WWDC 2014 video What's New in Interface Builder, in the Live Views demonstration, they describe that the first step is to ensure that the designable class is in a separate custom framework target. That video demonstrates the process for creating this custom framework target within the project.

If that's not issue. I'd suggest cleaning your project ("Clean" on "Product" menu) and rebuilding just the custom framework target to make sure that's ok before you try doing anything in IB, itself. Bottom line, make sure that the framework can be built without incident. If the problem still persists after doing that, I'd take it to the next level and (a) find the Xcode derived data folder; (b) quit Xcode; (c) clear the derived data folder, (d) restart Xcode, and (e) trying building the framework target again.

Edit:
Above link seems to be dead. Video can be downloaded directly from: http://devstreaming.apple.com/videos/wwdc/2014/411xx0xo98zzoor/411/411_hd_whats_new_in_interface_builder.mov?dl=1

There is also a github gist with links to all the 2014 material: https://gist.github.com/jianpx/eea1e938d5868e980b11

like image 167
Rob Avatar answered Oct 05 '22 18:10

Rob


I was still having this issue (in Xcode 8.3.3) even after moving my IBDesignable classes into a separate framework. What worked for me was to open the offending Xib file, uncheck Editor > Automatically Refresh Views, and then restart Xcode.

like image 35
M. Daigle Avatar answered Oct 05 '22 19:10

M. Daigle