Could not display instance of IB Designables

I have a mixed dynamic structure of Objective-C and Swift. And the mixed structure was associated with two pure dynamic Objective-C structures.

When I tried to mark any class in a mixed structure with IB Designable and using that class in a storyboard or nib, Xcode always says that an instance of it was not shown.

And an error message appeared:

IB Designables: Failed to display an instance of WZUITokenField: dlopen (WZUIKit.framework, 1): library not loaded: /Library/Frameworks/WZFoundation.framework/WZFoundation Link to: WZUIKit.framework Reason: image not found

IB Designables: failed to update the status of the automatic layout: dlopen (WZUIKit.framework, 1): library not loaded: @ rpath / WZFoundation.framework / WZFoundation Link to: WZUIKit.framework Reason: image not found

The WZUIKit structure is a mixed Objective-C and Swift structure, and WZFoundation is a pure Objective-C.

In addition, all of these sutff functions work on any device or simulator.

+58
objective-c xcode swift interface-builder ibdesignable
Nov 07 '14 at 10:24
source share
14 answers

Finally, I solved this problem by adding $(CONFIGURATION_BUILD_DIR) to the Runpath Search Paths build target configuration field.

In addition, there are a few additional steps that you may need for your Xcode.

  • Clear Xcode derived data for the project. They are in ~/Library/Developer/Xcode/DerivedData
  • Clear the current assembly by pressing K
  • Create your own project
  • In the storyboard, go to the Editor menu and do Refresh All Views ; wait for the assembly to complete and there should be no errors.

Credit @Mojtaba

+77
Nov 08 '14 at 1:15
source share

If you have the same problem creating a Mac application, adding @loader_path/../Frameworks to Runpath Search Paths resolved this for me.

+18
Jan 10 '15 at 21:24
source share

for me it works to close xcode and reopen it again. No error after. Thank.

+13
Aug 30 '15 at 17:07
source share

Interesting.

Firstly, WeZZard's answer made me go in the right direction, but was not my decision.

In my iOS project, something redefined the Runpath Search Paths field for my purpose. It looked like this:

 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 

I tried his decision to add $(CONFIGURATION_BUILD_DIR) , but that did not work for me. Since it did not work, out of habit I simply deleted the configuration entry (returning to the project defaults). When I did this, reset:

 LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 

which, if I enter my xcconfig files, appears from Cocoapods.

It seems that Alex has the @loader_path value, but this is slightly different from iOS than Mac OS X.

+5
Mar 09 '16 at 9:30
source share

I encountered this error on a platform containing IBDesignables.

I had to add $(FRAMEWORK_SEARCH_PATHS) LD_RUNPATH_SEARCH_PATHS $(FRAMEWORK_SEARCH_PATHS) to the LD_RUNPATH_SEARCH_PATHS parameter in my target structure.

After updating the settings for the execution path, creating and updating the view in the storyboard, the error disappeared. It was not even necessary to clean the assembly folder.

enter image description here

+5
May 18 '18 at 14:21
source share

I had the same problem. In Xcode 6.4, adding test memberships to the storyboard fixed these errors for me.

Also my test target @loader_path/Frameworks set to Runpath Search Paths for the target, not the original target.

enter image description here

+4
Jul 10 '15 at 18:17
source share

I just found out one more reason in my case:

When I used "Editor -> Debug Selected Views", I saw that it crashed because I used CoreGraphics to create the image and used it as the background image for the button:

 class func imageWithColor(color: UIColor, size: CGSize) -> UIImage { let rect = CGRectMake(0.0, 0.0, size.width, size.height); UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0); let context = UIGraphicsGetCurrentContext(); // It alraedy nil here :( CGContextSetFillColorWithColor(context, color.CGColor); CGContextFillRect(context, rect); let image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; } 

The reason is because the size is (0.0, 0.0). Why is this? I'm calling

 super.setBackgroundImage(UIImage.imageWithColor(bgColor, size: self.bounds.size), forState: .Normal) 

But in IB self.bounds.size is still 0 at this point! So I changed one line:

 let rect = CGRectMake(0.0, 0.0, max(size.width, 1.0), max(size.height, 1.0)); 

And now it works :)

Apple should provide a list with Dos and Don'ts regarding IB ...

+3
Apr 21 '16 at 5:28
source share

I also tested this on a Mac project and Xcode 7.3.1. In my case, the framework specified in the Failed to Render error message was not related to drawing at all.

By simply going to the target tab General / Associated frameworks and libraries and changing the status of the violating framework from Mandatory to Optional, IBDesignables can be updated and drawn correctly in IB.

optional status

+3
Aug 22 '16 at 16:42 on
source share

In my case, I did the following in the initWithFrame / initWithCoder methods to create the view:

 className = NSStringFromClass([self class]); self.view = [[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil] firstObject]; 

But it looks like I shouldn't have used the Main Bundle, but a package of this class. So I replaced this code with the following and it worked:

 bundle = [NSBundle bundleForClass:[self class]]; className = NSStringFromClass([self class]); self.view = [[bundle loadNibNamed:className owner:self options:nil] firstObject]; 

I thought maybe this could help someone.

+1
Feb 14 '16 at 21:46
source share

I had this problem in an OS X project.

In my case, the problem was an old project ( NMSSH ) containing a frame target with poor build settings. In particular:

  • INSTALL_PATH set to @executable_path/../Frameworks , but the correct option is /Library/Frameworks
  • SKIP_INSTALL not set and the default is NO , but the correct parameter is YES
  • DYLIB_INSTALL_NAME_BASE not been set, but @rpath configured @rpath

Please note that all the correct settings are what you get automatically for the newly created target environment.

After changing the settings to the correct values, Xcode was able to load my @IBDesignable view in the storyboard.

+1
May 20 '16 at 3:33
source share

Follow these steps:

  • If there are any conflicts in the storyboard, resolve them correctly, check that the XML code is validated (this is the main step.)
  • Clean up the project.
  • Delete the folder with the derived data.
  • Close Xcode and restart it again. (I had to do this twice.)
0
Nov 03 '17 at 13:35
source share

I had a similar error that was caused by my Framework views that did not have public initializers:

 public override init(frame: CGRect) { super.init(frame:frame) commonInit() } required public init(coder: NSCoder) { super.init(coder: coder) commonInit() } 
0
Dec 07 '18 at 14:51
source share

Clear derived data. Exit Xcode, open again.

0
Jan 11 '19 at 15:39
source share

In my case, it is inside a private pod. Xcode version 10.3 (10G8) produce rendering error

The clause in my case is very simple - I just forget to add public between @IBInspectable var

correct option:

 import UIKit @IBDesignable public class BorderedView: UIView { @IBInspectable public var borderColor: UIColor? = UIColor.white { didSet { if let actualColor = borderColor { layer.borderColor = actualColor.cgColor } else { layer.borderColor = UIColor.white.cgColor } setNeedsDisplay() } } @IBInspectable public var borderWidth: CGFloat = 1 { didSet { layer.borderWidth = borderWidth setNeedsDisplay() } } } 

PS Editor: → Debugging selected views in my case did nothing

PS2: The AlignedCollectionViewFlowLayout module is dependent on my private module and is definitely not relevant to this problem.

PS3: the problem is still here

0
Aug 28 '19 at 16:23
source share



All Articles