title: UIKit crash when instantiating a Storyboard containing a UIScrollView
body: <p>I everyone,</p>
  
  <p>I'm facing a strange issue with UIKit, that I'm not able to reproduce at every app launch. The problem is very simple: I have a main <code>ViewController</code> and a child <code>ViewController</code> that contains a <code>UIScrollView</code>. You can see it as the following image:</p>
  
  <p><a href="https://i.stack.imgur.com/qW42Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qW42Q.png" alt="enter image description here"></a></p>
  
  <p>My code to add the child controller is pretty simple:</p>
  
  <pre class="lang-swift prettyprint-override"><code>private func configureKeyboard() {
      guard let keyboardViewController = keyboardViewController else { return }
  
      addChild(keyboardViewController)
  
      keyboardContainerView.addSubview(keyboardViewController.view)
      keyboardViewController.didMove(toParent: self)
      keyboardViewController.view.translatesAutoresizingMaskIntoConstraints = false
  
      keyboardContainerView.topAnchor.constraint(equalTo: keyboardViewController.view.topAnchor, constant: 0).isActive = true
      keyboardContainerView.trailingAnchor.constraint(equalTo: keyboardViewController.view.trailingAnchor, constant: 0).isActive = true
      keyboardContainerView.bottomAnchor.constraint(equalTo: keyboardViewController.view.bottomAnchor, constant: 0).isActive = true
      keyboardContainerView.leadingAnchor.constraint(equalTo: keyboardViewController.view.leadingAnchor, constant: 0).isActive = true
  }
  </code></pre>
  
  <p>But the line <code>keyboardContainerView.addSubview(keyboardViewController.view)</code> seems to cause a crash:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception
    'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate
    class named _UIScrollerImpContainerView because no class named
    _UIScrollerImpContainerView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part
    of the correct target)'</p>
  </blockquote>
  
  <p>So it seems like the scrollView is the cause of the crash. The stack show me that it seems to be falling on <code>init(coder:)</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/4oscI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4oscI.png" alt="enter image description here"></a></p>
  
  <p>Here is the way I'm instantiating my <code>KeyboardController</code>. The controller itself is initiated on a Coordinator during the <code>scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)</code>:</p>
  
  <pre class="lang-swift prettyprint-override"><code>class func controller(dataSource: KeyboardDataSource,
                        stackEditor: StackEditor,
                        onOperationTouch: @escaping (_ operation: CalculatorOperation) -&gt; Void,
                        onShouldPresentSettings: @escaping () -&gt; Void) -&gt; KeyboardViewController {
      let controller: KeyboardViewController = UIStoryboard(name: "KeyboardViewController", bundle: nil).instantiateInitialViewController() as! KeyboardViewController
      controller.dataSource = dataSource
      controller.stackEditor = stackEditor
      controller.didTouchOperation = onOperationTouch
      controller.shouldPresentSettings = onShouldPresentSettings
      return controller
  }
  </code></pre>
  
  <p>This crash kinda reminds me the crash we had with UITextView on as earlier version of Xcode that can cause a crash. I'm calling <code>configureKeyboard</code> on <code>viewDidLoad()</code>. Putting it on <code>viewDidAppear()</code> doesn't fix the issue. I should also say that Catalyst is enabled on the app. But I only see this crash on the iOS app. Works perfectly on the Mac.
  Sometimes, cleaning build folder and deleting the app seems to fix the issue. But I'm scared of deploying a version on the AppStore with such a random crash. This happen on a real device too. So probably not a simulator issue.
  Also, the Storyboard file of the <code>KeyboardController</code> is correctly associated to the iOS app target. Nothing on Apple Developer's forum. I'm out of idea.</p>
  
  <p>Does someone encountered some familiar issue ?</p>
  
  <p>Thanks in advance for your help.</p>