title: SwiftUI: NSPageController in NSViewControllerRepresentable crashes
body: <p>Im' trying to put a <code>NSPageController</code> in a SwiftUI <code>NSViewControllerRepresentable</code> programatically, but when the app runs, it crashes with the following error:</p>
  <pre><code> -[NSNib _initWithNibNamed:bundle:options:] could not load the nibName: test.PageController in bundle (null).
  
  </code></pre>
  <p>This is the smallest example I could think off to demonstrate the problem:</p>
  <p><strong>PageView:</strong></p>
  <pre><code>struct PageView: NSViewControllerRepresentable {
      
      let data = [&quot;green&quot;, &quot;blue&quot;, &quot;red&quot;]
      
      typealias NSViewControllerType = PageController
      
      func makeNSViewController(context: Context) -&gt; PageController {
          let pageController = PageController()
          pageController.arrangedObjects = data
          pageController.delegate = pageController
          return pageController
      }
      
      func updateNSViewController(_ nsViewController: PageController, context: Context) {
          
      }
      
  }
  </code></pre>
  <p><strong>PageController:</strong></p>
  <pre><code>class PageController: NSPageController, NSPageControllerDelegate {
      
      func pageController(_ pageController: NSPageController, identifierFor object: Any) -&gt; NSPageController.ObjectIdentifier {
          return (object as? String) ?? &quot;green&quot;
      }
      
      func pageController(_ pageController: NSPageController, viewControllerForIdentifier identifier: NSPageController.ObjectIdentifier) -&gt; NSViewController {
          let rootView: Color
          switch identifier {
          case &quot;green&quot;:
              rootView = .green
          case &quot;red&quot;:
              rootView = .red
          default:
              rootView = .blue
          }
          return NSHostingController(rootView: rootView)
      }
      
  }
  </code></pre>
  <p>So far I tried creating custom initialisers that call <code>super.init(nibName: nil, bundle: nil)</code> on <code>NSPageController</code>, but that didn't work either. Ive also tried overwriting 'loadView', but I still didn't get it to work.</p>
  <p>I did find that the app crashes in the <code>loadView</code> call of the <code>NSPageController</code> inside the <code>makeNSViewController</code> call.</p>