title: Could not dequeue a view of kind: UICollectionElementKindCell with identifier - must register a nib or a class for the identifier
body: <p>This is driving me insane. I've put together dozens of collections views in the past, but this one is refusing to work.</p>
  
  <p>I have a xib for my collection view cell, and I gave it an identifier, "My Cell". In my controller, I do the following:</p>
  
  <pre><code>    override func awakeFromNib() {
          super.awakeFromNib()
  
          myCollectionView.delegate = self
          myCollectionView.dataSource = self
  
          // Register the collection view cell
          myCollectionView.register(UINib(nibName: "MyCell", bundle: nil), forCellWithReuseIdentifier: "MyCell")
      }
  
      func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
          guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MyCell", for: indexPath as IndexPath) as? MyCell else {
                  fatalError("The dequeued cell is not an instance of MyCell.")
          }
  
          return cell
      }
  </code></pre>
  
  <p>Yet no matter what I do, Xcode is crashing and giving me this error:</p>
  
  <blockquote>
    <p>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier MyCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'</p>
  </blockquote>
  
  <p>I've tried cleaning the build folder, restarting Xcode, even restarting my Mac, and nothing works.</p>
  
  <p>What am I doing wrong??</p>