Live Rendering a custom component using IB_DESIGNABLE from a pod dependency
Asked Answered
S

3

21

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:

enter image description here

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)"

Singlestick answered 25/10, 2014 at 21:53 Comment(4)
I have the same issue when the class having IB_DESIGNABLE is in a dependent project (e.g. framework project)Bondage
I have the same issue too. If "MyCustomView" is in my project, it works great, but if this class is in the Pods project it doesn't work anymore. I get the same error: "failed to load designables from path (null)" (I'm writing it here to find this thread more easily on Google ! ).Luane
Any chance that importing the designable classes in a framework in the main project would fix it? Going to try that and report back.Calesta
Followup: framework didn’t work. I posted a sample project on this CocoaPods bug: github.com/CocoaPods/CocoaPods/issues/2792Calesta
S
19

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.

Singlestick answered 23/1, 2015 at 10:51 Comment(2)
Yes, unfortunately that's correct. Dynamic frameworks are only available in iOS 8 and there doesn't seem to be any way to make IB_DESIGNABLE work with static libraries. You could drag and drop the source files for the dependency in question instead of using cocoapods, if you really want IB_DESIGNABLE to workSinglestick
if I use 'use_frameworks!' This impacts my other library's pods error erros , can you suggest how I can apply this for only specific pod '' only.Radiochemical
D
0

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.

Dividers answered 27/11, 2014 at 20:17 Comment(2)
Modules only need to be specified if you are using Swift, not with Objective-C. My sample project uses Objective-C.Singlestick
Does your library also have depencies on other frameworks which need to be located via @rpath? If that is the case, you should notice system logs in Console showing the failure that occured when resolving the dependencies.Dividers
P
0

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.

Psychopathy answered 10/7, 2015 at 15:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.