Failed to render instance of IB Designables

2019-01-12 23:08发布

I have an Objective-C and Swift mixed dynamic framework. And the mixed framework was linked with two pure Objective-C dynamic frameworks.

When I tried to mark any class in the mixed framework with IB Designable and using that class in either storyboard or nib, the Xcode always says the instance of it was failed to render.

And there was the error message:

IB Designables: Failed to render instance of WZUITokenField: dlopen(WZUIKit.framework, 1): Library not loaded: /Library/Frameworks/WZFoundation.framework/WZFoundation Referenced from: WZUIKit.framework Reason: image not found

IB Designables: Failed to update auto layout status: dlopen(WZUIKit.framework, 1): Library not loaded: @rpath/WZFoundation.framework/WZFoundation Referenced from: WZUIKit.framework Reason: image not found

The framework WZUIKit is an Objective-C and Swift mixed framework and the WZFoundation is pure Objective-C.

Plus, all these sutff work on either device or the simulator.

13条回答
啃猪蹄的小仙女
2楼-- · 2019-01-13 00:03

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

Simply going to the target's General/Linked Frameworks and Libraries tab and changing the offending framework's Status from Required to Optional allowed the IBDesignables to update and draw properly in IB.

optional status

查看更多
聊天终结者
3楼-- · 2019-01-13 00:03

Clear Derived Data . Quit Xcode, Reopen again.

查看更多
看我几分像从前
4楼-- · 2019-01-13 00:04

for me it works to close xcode and reopen it again. No errors after. Thanks.

查看更多
smile是对你的礼貌
5楼-- · 2019-01-13 00:05

Interesting.

First, WeZZard's answer got me going in the right direction but wasn't exactly my solution.

In my iOS project, something had overridden the Runpath Search Paths field in my target. It looked like this:

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

I tried his solution of adding the $(CONFIGURATION_BUILD_DIR) but it didn't work for me. Since it wasn't working, out of habit I just deleted the configuration entry (going back to project defaults). When I did, it reset to this:

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

which if I dig into my xcconfig files, appears to come from the Cocoapods.

It seems same as Alex that the @loader_path is key, but it's a slightly different path on iOS than it is Mac OS X.

查看更多
beautiful°
6楼-- · 2019-01-13 00:07

I had this problem in an OS X project.

In my case, the problem was an old project (NMSSH) containing a framework target with bad build settings. Specifically:

  • INSTALL_PATH was set to @executable_path/../Frameworks, but the correct setting is /Library/Frameworks
  • SKIP_INSTALL was not set and defaults to NO, but the correct setting is YES
  • DYLIB_INSTALL_NAME_BASE was not set, but the correct setting is @rpath

Note that all of the correct settings are what you get automatically for a newly-created framework target.

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

查看更多
\"骚年 ilove
7楼-- · 2019-01-13 00:08

If you have the same issue building a Mac App, adding @loader_path/../Frameworks to Runpath Search Paths solved this for me.

查看更多
登录 后发表回答