I just had the exact same issue, and the only thing that worked for me was instead of using the main Bundle I had to get the Bundle for the Nib I wanted. Essentially changing:
Bundle.main.loadNibNamed("UserView", owner: self, options: nil)
To:
let bundle = Bundle(for: UserView.self)
bundle.loadNibNamed("UserView", owner: self, options: nil)
Which is bizarre, as in my case when comparing the two Bundles at runtime in LLDB they were identical (class name is different but the rest of my setup was identical to the OP)
Updated
Why loading NIB from main bundle does not work?
Because when InterfaceBuilder is rendering it is not running the application. There is no "main application bundle".
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…