I had a MyViewController.swift and a MyViewController.xib presenting the layout of MyViewController.
MyViewController.swift
MyViewController.xib
I tried different methods to load this
extension UIViewController { static func loadFromNib() -> Self { func instantiateFromNib() -> T { return T.init(nibName: String(describing: T.self), bundle: nil) } return instantiateFromNib() } }
Use it as the following:-
let testVC = TestVC.loadFromNib()