Live Rendering a custom component using IB_DESIGNABLE from a pod dependency

做~自己de王妃 提交于 2019-11-30 12:37:03

问题


I'm having some difficulty using IB_DESIGNABLE in a pod.

I created a custom view which I marked as IB_DESIGNABLE and made a sample project that uses it. No problems so far.

The issue happens when adding that custom view as a pod dependency. Although the project builds and runs successfully, there is an error when the storyboard that uses the custom view is opened. The Live Rendering process starts and tries to show the view live inside Interface builder but it fails with the following error:

This is too bad because we lose Live Rendering which is, in my opinion, one of the best features from Xcode 6.

  • Cocoapods gem version: 0.34.4
  • Xcode version: 6.1 (6A1052d)

I've tried with other projects that use IB_DESIGNABLE and have a podspec:

  1. https://github.com/Eddpt/EAColourfulProgressView (Class: EAColourfulProgressView)
  2. https://github.com/hayashi311/HRButton (Class: HRButton)
  3. https://github.com/Estimote/iOS-Indoor-SDK (Class: ESTIndoorLocationView)

Someone else had the same issue in Estimote - Indoor Location Error but the solution described means losing Live Rendering capabilities.

Has anyone been able to use a IB_DESIGNABLE component through Cocoapods?

Error: "failed to load designables from path (null)"


回答1:


This has been fixed in the latest version of Cocoapods (0.36.0.beta.1).

To install this version:

[sudo] gem install cocoapods --pre

More information about Cocoapods with frameworks here

In order to fix the Error: "failed to load designables from path (null)":

platform :ios, '7.0'

use_frameworks!

target 'test' do
pod 'EAColourfulProgressView', '~> 0.1.0'
end

target 'testTests' do

end

Add use_frameworks! to you Podfile.




回答2:


When specifying your custom class in the Identity Inspector, are you specifying from which module this class should be loaded? The module should be the name of the library the class comes from.




回答3:


I Resolved my problem using use_frameworks! on the PodFile, in the first Line. (don't forget the !)

IBInspectable properties must be Dynamic, so it asks for a Dynamic Linkage of the Library. By using the above line, as soon as you set the class of a control, it will build the framework and link it, resolving this binding issues. When I upgraded to beta, Parse stopped working.

Hope it helps someone.



来源:https://stackoverflow.com/questions/26567650/live-rendering-a-custom-component-using-ib-designable-from-a-pod-dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!