IB Designables Failed to render and update auto layout status for ViewController

Hello all,

Code Block
IB Designables Failed to render and update auto layout status for ViewController

After updating to XCode 12.1 I get this error every time I open Main.storyboard.
I have 3 custom view classes for UIButton, UITextField, UITextView, etc.
Tried to update pods and I've deleted DerivedData folder but that didn't fix the issue.
What could I do in order to overcome this stubborn issue?

Thanks in advance!

Replies

For what it's worth.

I have a project with IBDesignable.
I opened in Xcode 12.1 and they show on screen in IB normally.
But I have no Pod.

Did you try using prepareForInterfaceBuilder ?

https://stackoverflow.com/questions/26197582/is-there-a-way-for-interface-builder-to-render-ibdesignable-views-which-dont-ov
But now I opened another project with Xcode 12.1 and got IBDesignable error.
With the following message :

Failed to launch designable agent because tool was shutting down. Check the console for a more detailed description and please file a bug report.

There are no message in the console…

However, I opened the same code with Xcode 12.2 beta, and IBDesignable renders OK.
So I'll wait for Xcode 12.2. to check if this is stabilised..

There seem to be errors in Xcode 12 converting storyboard to its new internal structure.
See another problem in this thread:
https://developer.apple.com/forums/thread/665777

Maybe you should get a look at the source for mainStroryboard file, you may find something ?
I may have found a solution to the problem, even for Xcode 12.1.

Update the project to recommended settings, as proposed in Issue Navigator.

That apparently corrects the storyboard XML and now IBDesgnable show as intended.

Please report if that works for you.
I've got the same problem and also found a solution (well at least kind of).

This problem is very easy to reproduce on my Mac Mini M1 and Xcode 12.3.
  1. Create a new UIKit project

  2. Create a custom component class (e.g. like the code below)

  3. Add a UIButton to your main ViewController

  4. In the Identity inspector, change the button class to your custom component

Now the custom component will not be rendered in the IB and you will find an error message in the Issue Navigator. The only way to have it rendered is to change the build setting "Build Active Architecture Only" for Debug to "No" (instead of the default "Yes"). Now the custom button is rendered correctly in IB without the error message. Instead you get another message suggesting to revert to recommended settings. I have not encountered this problem on my MacBook Pro (Intel processor) so I guess this is only related to the M1 and the IB.


import UIKit

@IBDesignable class CustomRoundedButton: UIButton {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        commonInit()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        commonInit()
    }
    
    override func prepareForInterfaceBuilder() {
        commonInit()
    }

    private func commonInit() {
        self.clipsToBounds = true
        self.layer.cornerRadius = self.bounds.size.height / 2
    }
}
  • "Build Active Architecture Only" for Debug to "No"

    Thank you, it solves the problem on M1

Add a Comment
@macke 

I tested in Xcode 12.2. MacOS Catalina 10.15.7

I added a red background for the layer to properly see it.
Code Block
private func commonInit() {
self.clipsToBounds = true
self.backgroundColor = .red
self.layer.cornerRadius = self.bounds.size.height / 2
}

At first, didn't work, even though Designables were declared up to date.

I closed the project and reopened, then it was OK, I did see the red, roundedcorner UIButton.

Works as well on Xcode 12.3.
@Claude31

Yes, I see that you are using Catalina which means that you do not have a M1 Mac. This issue seems to be related to M1 Macs only.
I have the same problem since I've updated to 12.3
Tried building the entire project again but it always fails over there...
I am using an Intel based Macbook Pro
I had the same problem. But it was a very simple problem, restarting the computer solved the problem.

https://developer.apple.com/forums/thread/120250
  • That worked for me like a magic.

Add a Comment

Another gotcha to look our for are things in asset catalogues such as colours. i.e.

var mycol = UIColor(named: "mycol")!

will crash because the colour can't be found in whatever context the xib is running. Do this instead:

var mycol = UIColor(named: "mycol", in: Bundle(for: MyView.self), compatibleWith: nil)!

safari

Is there any news on this? I am still facing this issue with XCode 13.2.1 on my MacBook Pro (13-inch, M1, 2020) running mac OS 12.0.1. Sometimes it works, and sometimes it doesn't, and I couldn't figure out why and when it works and when not. It seems like occurring randomly. I have already tried different build settings etc.

  • Unfortunately, the only answer I ever got is 'it depends'…

    Did you do a Clean Build Folder and reboot the Mac ?

  • Yes, I tried multiple times. Nevertheless, thanks for the fast reply!

  • I actually made it work now. My fault was, that I have overseen one UIColor definition in which I got color from the asset catalog. However, as already mentioned by @kemalenver, that is not possible. After changing this, I do not get any further errors.

Add a Comment

Just sharing:

My primary strategy has been to keep any IBDesignables in a separate module (framework target).

  • That separates the build phase for those views from the main project (by building the framework prior to opening the storyboard in the main project)
  • So it renders instantly when there are no programming errors.

Open Storyboard editor. Find all the devices (screeenshot below) . Change for the newer device to show.Run.