Embedded Framework - Swift Classes not in Interface Builder

I was recently running into an issue where I have a compiled framework that I embed into another application. This framework has both Objective-C and Swift code in it. The problem I was having was that none of my swift subclasses of UIKit based objects, such as UIViewController or UICollectionViewCell, were showing up for usage inside interface builder in my main project. All of the classes were available through use direclty in code though.


After several days I finally discovered that the issue was if ANY of my swift UIKit classes used extensions, custom or things like UICollectionViewDelegate, then none of my siwft classes would be available in interface builder. However, if I moved the protocol implementations inside the class itself rather than an extension everything becomes available.


I am assuming this has something to do with the compilation process of the code that it is generating something that makes interface builder unable to detect any of the swift UIKit classes.


I was curious if anyone had experienced a similar issue. Are there any build settings or anything like that I could set that would allow me to still implement protocols through extensions without making all of my UIKit classes unavailable in interface builder? Or any guess as to what the cause of the issue might be?


Another similar issue I noticed was implementing an extension of a Objective-C NSObject subclass in order to override the 'isEqual' method, which had the same effect on my swift classes, unavailable in interface builder but available through code.


Still fairly new to Swift so trying to get a grasp on build settings or anything else that may cause me issues in these areas. It's not blocking my development now that I have a workaround but it would still be nice to know if there is something I can do about it. Thanks

Is this something you can reduce to a small sample project that you could post in DropBox or somewhere?


I can think of two things that might be related to behavior like this, but neither of them exactly fit the scenario you describe:


1. If you declare a public subclass, anything you declare in an extension is still internal by default. (However, public protocol conformances added via extension should be public.)


2. In IB, when using classes from a module other than the target's module, you might need to specify the module name explicitly in the second text field of the Identity inspector (just below the text field where you choose the custom class name). I don't see why this should differ based on how the subclass is itself broken up into extensions, but it might be relevant somehow.

Sorry for the delayed reply, but I broke the issue down into 2 sample projects. One is the framework and one is the project integrating the framework.


Inside the project is an 'ExampleViewController' that can be use in interface builder in the integration project by default.


I have a commented out UICollectionViewDelegate extension in the view controller that if uncommented when rebuilding the framework and dropping it into the integration project makes the view controller no longer available for use.


I also have a separate 'CustomObjectExtension' file with an extension to an Objective-C NSObject class that if uncommented will have the same effect.


Any clarification as to why this happens is greatly appreciated.


https://www.dropbox.com/s/cysgwgp597x008d/ExampleProjects.zip?dl=0

Embedded Framework - Swift Classes not in Interface Builder
 
 
Q