title: my custom framework crashing 'Could not load NIB in bundle
body: <p>I  have a custom framework which includes one xib and a UIView class for the same.</p>
  
  <p>when I connect my test app with the framework, it got crashed </p>
  
  <pre><code> *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle &lt;/private/var/containers/Bundle/Application/10A66571-E4BA-4C82-BDCE-82DA8018CA1C/cam.app&gt; (loaded)' with name 'scanner''
  *** First throw call stack:
  (0x1b318bab0 0x1b2ea5028 0x1b307b2fc 0x1b6efbb4c 0x1b6efc9e4 0x104902338 0x104901e68 0x104902078 0x1048a7c60 0x1048a74d8 0x1048a740c 0x1048a7514 0x1b6c29994 0x1b6c2e5c8 0x1b6c2e9b4 0x1b72a9c58 0x1b72a9354 0x1b72aa2f0 0x1b72bb4d4 0x1b74ab924 0x1b68729ac 0x1b726d370 0x1b726d700 0x1b6e08dec 0x1b8355ec0 0x1b837cb50 0x1b8360fa4 0x1b837c7e4 0x104cab27c 0x104cae9a4 0x1b83a3304 0x1b83a2fb0 0x1b83a351c 0x1b310724c 0x1b31071a0 0x1b310695c 0x1b31017d8 0x1b3101084 0x1bd34f534 0x1b7271670 0x1048a867c 0x1b2f80e18)
  libc++abi.dylib: terminating with uncaught exception of type NSException
  
  </code></pre>
  
  <p>my framework code </p>
  
  <pre><code>import UIKit
  import QKMRZScanner
  public class scanner: UIView,QKMRZScannerViewDelegate {
  
      @IBOutlet var mrzScannerView: QKMRZScannerView!
  
      public func mrzScannerView(_ mrzScannerView: QKMRZScannerView, didFind scanResult: QKMRZScanResult) {
          print(scanResult.documentType)
      }
  
      override  init(frame: CGRect) {
          super.init(frame: frame)
          commitinit()
          mrzScannerView.delegate = self
      }
  
  
      required init?(coder: NSCoder) {
          fatalError("init(coder:) has not been implemented")
      }
  
      private func commitinit(){
          Bundle.main.loadNibNamed("scanner", owner: self, options: nil)
          addSubview(mrzScannerView)
          mrzScannerView.frame = self.bounds
          mrzScannerView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
      }
  
      public func capture(){
          mrzScannerView.startScanning()
      }
  
  
  }
  
  
  </code></pre>
  
  <p>my test app code below</p>
  
  <pre><code>import UIKit
  
  import testfrme
  class ViewController: UIViewController {
  
      @IBOutlet weak var tt: scanner!
      override func viewDidLoad() {
          super.viewDidLoad()
          let d = scanner()
          d.capture()
  
      }
  
  
  }
  
  
  
  
  </code></pre>
  
  <p>can anyone help me to understand why its crashing ??
  full source code of both available here
  <a href="https://www.dropbox.com/s/0xzkdlej51kv8xq/app.zip?dl=0" rel="nofollow noreferrer">testapp code</a>
  <a href="https://www.dropbox.com/s/strcy5vjosv7ajz/sdk.zip?dl=0" rel="nofollow noreferrer">framework code</a></p>
  
  <p><strong>updated:</strong></p>
  
  <p>new crash screenshot 
  <a href="https://i.stack.imgur.com/ESbhE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ESbhE.png" alt="enter image description here"></a></p>
  
  <p><strong>UPDATED :</strong> </p>
  
  <p>When i tried </p>
  
  <pre><code>        mrzScannerView = Bundle(for: QKMRZScannerView.self).loadNibNamed("QKMRZScannerView", owner: self, options: nil)
  
  
  </code></pre>
  
  <p>am getting below error
  <a href="https://i.stack.imgur.com/ESbhE.png" rel="nofollow noreferrer">!enter image description here</a>]<a href="https://i.stack.imgur.com/ESbhE.png" rel="nofollow noreferrer">3</a></p>
  
  <p>My xib connections look like this
  <a href="https://i.stack.imgur.com/1v1HU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1v1HU.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/ewqsZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ewqsZ.png" alt="enter image description here"></a></p>