Sakiboy Sakiboy - 6 months ago 110
iOS Question

IBDesignable from External Framework?

I'd like to create some custom views that use the

@IBDesignable
and
@IBInspectable
tags. I have added these to my Framework and then linked my Framework to my test application. But the Designables never show up in the StoryBoard.

How can I use
@IBDesignable
and
@IBInspectable
to create custom views from an external framework?

Can you use
@IBDesignable
and
@IBInspectable
in an application from a non-embedded Framework?

Thank you.

Answer

Alright, so apparently if you want to include @IBDesignable and @IBInspectable in a framework the framework has to either be:

  • Included WITHIN the consuming application, so the Framework will not be in it's own project. (i.e. adding a framework as a target by doing something like 'file -> new.. -> target -> framework' from consuming application).
  • Include the external framework as a CocoaPod in your consuming application. This actually adds the framework as a target rather than just linking the framework against the application.
    • There is a way to include local CocoaPods in a project, so don't worry you don't have to deploy your framework to the public just to do this.
  • Maybe using a different dependency manager like Carthage (haven't tried this myself, but I bet it'd work).