Ben10
Ben10

Reputation: 3259

Xcode 10.1 - "IB Designables. Failed to render and update auto layout status". The agent crashed

I have an issue where my storyboard failed to render the layout, so I can't add constraints and also can't see the layout of my viewController.

Issues Image

How can I resolve this?

Upvotes: 7

Views: 6389

Answers (2)

Eray Alparslan
Eray Alparslan

Reputation: 814

All the previous answers did not help, but I figured it out.

In the @IBInspectable didSet property I was calling the common setup() function to utilize my view. However, I was trying to adjust a textField without checking whether it was nil or not. That's why I was getting "failed to render" problem and also a run time crash.

For example:

@IBInspectable var isTitleEnabled: Bool = true{
    didSet{ setup() }
}

And the setup() function was:

private func setup(){
    textField.isSecureTextEntry = isPassword
}

which is wrong. Xcode doesn't allow the subviews to be modified in this way.

When the Interface Builder (IB) component is rendered, Xcode thinks that it is not initialized yet, so it raises an error. To solve this misunderstanding, we need to make sure that the Interface Builder component is not nil.

So, instead we need to use it like that:

guard textField != nil else { return }
textField.isSecureTextEntry = isPassword ? true : false

The Interface Builder component don't need only to be a UITextField. It is valid for other Interface Builder components like UILabel, UIImageView, etc.

Upvotes: 2

Sterli
Sterli

Reputation: 57

See the answer @IBDesignable error: Failed to update auto layout status.

Or just try go to EditorRefesh All Views in your Storyboard selection.

Upvotes: 1

Related Questions