Missing IBOutlets of a superclass from a binary framework

I created a swift binary framework with view controllers inside it. The view controllers contains iboutlet properties like button, label, etc. But when I subclassed the view controller the outlets are missing in the interface builder. Even the modules are missing in the identity inspector.

So this is how I understand it. You have viewcontrollers and xibs in a framework bundle. Then you subclassed that VC but it can’t find the outlets.

I think it can not load the xib file from the framework bundle since it was not told where is the Xib located.

Somehow you need to pass the bundle of the framework into the subclassed vc.

If you create an instance like so:

ViewController(nibName: String?, bundle: Bundle?)

In the bundle param you will pass the instance of the framework bundle.

For example:

let vcBundle = Bundle.main.url(forResource: "FrameworkName", withExtension: "bundle")
let vc = ViewController(nibName: "SubclassVC", bundle: vcBundle)

Let me know how it went.

You might want to watch a related video here(Obj-C): https://www.youtube.com/watch?v=WQI02KR9kQw

I can see the outlets in the code but when I am trying to hook the outlets in the interface builder the outlets are missing.

Can you share a screenshot of the project structure where we can see the issue?

Just guessing: Is the outlet public?

All outlets in my framework are public.
I just dragged the frameworks here.

08%20AM

This is what I expected to happen when I changed the class of the nib.
(I tried this inside the framework project.)

28%20AM

But when I tried to import the framework on another project. This is what happen, the outlets are missing and Xcode doesn’t even find the class im looking for when I try to change it to a custom class

30%20AM

Thank you! :smile:

As per our conversation on Slack, the framework is bundled in an XCFramework which made it impossible for IB to resolve the outlets. If I use just the .framework, the IBOutlets are resolved by Xcode.

If you are doing this to allow the framework user to customize the VC perhaps you can just create customization APIs or some configuration for the developer.