I have a IBDesignable class I am working on, and I have noticed that if I try to add a protocol to the class, it causes an error "Failed to render and update autolayout status"
If I take the protocol out, it works fine, however for some of the functions I will be trying to create, this would be very useful. Example code you can use to recreate the error
import UIKit
protocol TestProtocol {}
@IBDesignable class TestDesignableButton: UIButton {
var delegate: TestProtocol?
}
Does anyone know what causes this? And do you know if there is a way around this issue?
Thanks in advance
Change your protocol declaration to:
@objc protocol TestProtocol {}
Here it is, working in my tests (I changed your code a little, but not much — just enough make sure we have the bare bones working). Note that designable button is in fact green; it wouldn't be if the IBDesignable code were not working. Also it says "Up to date" in the inspector at the right.