Empty view UIViewController in a Storyboard won't load its view from a XIB in a different module

Originator:arnold.sakhnov
Number:rdar://32007596 Date Originated:2017/05/05
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 10.3
Classification: Reproducible:Every time
 
Summary:
Normally with UIStoryboards, a scene that contains a UIViewController whose view is empty will load the view for that UIViewController from a XIB that matches its name. This allows us to have "placeholder" Storyboard scenes with the views for those defined elsewhere.

The problem arises when the "elsewhere" is a different module. Since UIViewController's loadView only searches the main app bundle for a XIB with a matching name, it fails to load the view correctly in multi-module projects. It's worth noting that this behaviour is explicitly as-documented but likely unintended since its implementation predates dynamic frameworks on iOS. Additionally, macOS currently already handles this correctly.

Steps to Reproduce:
1. In Main.storyboard of a new Xcode project (A), remove the view from the initial UIViewController's scene.
2. Add the Xcode project to a workspace. Add another Xcode project (B) to that workspace that builds a framework target MyModule.
3. In Xcode project B, create a UIViewController subclass MyViewController and a matching MyViewController.xib file.
4. In Xcode project A’s Main.storyboard, set the class of the initial view controller to MyViewController (and observe Module changing to MyModule).
5. Run the app.

Expected Results:
The app runs, the Storyboard loads MyViewController’s view from MyViewController.xib and displays it.

Actual Results:
The app runs, but the Storyboard loads an empty UIView for MyViewController, resulting in a crash if MyViewController connects any IBOutlets from the XIB.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!