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

Powered by WPeMatico

About

You may also like...

Comments are closed.