When I write my own UIButton
-extended class and make it @IBDesignable
, I receive two errors in Interface Builder, namely:
- Main.storyboard: error: IB Designables: Failed to update auto layout status: The agent crashed because the fd closed
- Main.storyboard: error: IB Designables: Failed to render instance of RandjeUIButton: The agent crashed
Here is my code:
import UIKit
@IBDesignable
class RandjeUIButton: UIButton {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.backgroundColor = UIColor.blackColor()
}
}
I am working in Xcode 7 beta 2 on OS X 10.11 beta 2. (Running in VM)
In Xcode 7.3, none of the above solutions worked for me, but the accepted answer to this question did: Failed to render instance of IB Designables
I did not need to do the 4th step to solve the problem (and get my PaintCode-drawRect'd UIView to paint in the storyboard), included here just in case.
Credit to @Mojtaba and @WeZZard
This is how I solves this problem:
Usage:
I wasted a full day on this and finally I got my problem solved
I selected Build for target as 8.0 and it fixes everything for me.
I've met the same problem and solved it this way:
error: IB Designables: Failed to update auto layout status: The agent crashed
Then the Xcode will tell you where the prolem is. In my case I drop the
IBDesignable
before the class.Then I clean and rebuild it, the error disappeared
Just re-open a code on another Xcode setup System. In my case it Worked.
For me, it was not using
#if !TARGET_INTERFACE_BUILDER
that got me. Basically I had some code that would result in accessing a path in my Bundle...The problem is that when running in IB (and not in your app),
Bundle.main
isn't your app...So the answer to this is simply to review your
@IBDesignable UIView
code carefully and use#if !TARGET_INTERFACE_BUILDER
for anything (in my case calls toCoreLocation
for example) that doesn't make sense when running at design time.How I debugged and found this
This is what you see when using the
Editor -> Debug Selected View
while selecting your@IBDesignable UIView
in your storyboard:You'll then crash at the right location
In my case, as you can see
initXXXX
was doing anassert
, which was crashing at design time, because it was looking for a value in file in my Bundle — which is Xcode, at design time.