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!
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'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.
-
Create a new UIKit project
-
Create a custom component class (e.g. like the code below)
-
Add a UIButton to your main ViewController
-
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
}
}
@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.
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)!
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.
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.
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the
Apple Developer Forums Participation Agreement.
Forums
Apple Developer Program
Apple Developer Enterprise Program
App Store Small Business Program
MFi Program
News Partner Program
Video Partner Program
Security Bounty Program
Security Research Device Program