I lost half a day figuring this and I can\'t see a straight forward solution online.
I created an iOS CocoaTouch Framework. I have some private and public classes in it
Generic solution for controllers with .xib file
public extension UIViewController {
//** loads instance from right framework bundle, not main bundle as UIViewController.init() does
private static func genericInstance() -> T {
return T.init(nibName: String(describing: self), bundle: Bundle(for: self))
}
public static func instance() -> Self {
return genericInstance()
}
}
Use as
YourViewController.instance()