title: class extension not being called - unable to configure annotations on map
body: <p>I'm on Swift 5 and Xcode 11, currently trying to create a map with predefined annotations using custom images instead of the default markers. I've been playing around with Apple's sample code for <a href="https://developer.apple.com/documentation/mapkit/mapkit_annotations/annotating_a_map_with_custom_data" rel="nofollow noreferrer">AnnotatingMapWithCustomData</a> and could tailor it to what I needed. But once I tried to copy the code into my own project, the annotations showed up as default markers instead of the custom annotationViews I configured. </p>
  
  <pre><code>import UIKit
  import MapKit
  
  class MapViewController: UIViewController {
  
      @IBOutlet private weak var mapView: MKMapView!
  
      private var allAnnotations: [MKAnnotation]?
  
      private var displayedAnnotations: [MKAnnotation]? {
          willSet {
              if let currentAnnotations = displayedAnnotations {
                  mapView.removeAnnotations(currentAnnotations)
              }
          }
          didSet {
              if let newAnnotations = displayedAnnotations {
                  mapView.addAnnotations(newAnnotations)
              }
          }
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
          registerMapAnnotationViews()
  
          // Create the array of annotations and the specific annotations for the points of interest.
          allAnnotations = [ShrekAnnotation(), CoffeeAnnotation()]
  
          // Dispaly all annotations on the map.
          displayedAnnotations = allAnnotations
          centerMapOnLondon()
      }
  
      /// - Tag: RegisterAnnotationViews
      private func registerMapAnnotationViews() {
          mapView.register(MKAnnotationView.self, forAnnotationViewWithReuseIdentifier: NSStringFromClass(ShrekAnnotation.self))
          mapView.register(MKAnnotationView.self, forAnnotationViewWithReuseIdentifier: NSStringFromClass(CoffeeAnnotation.self))
      }
  
      private func centerMapOnLondon() {
          let span = MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)
          let center = CLLocationCoordinate2D(latitude: 51.507911, longitude: -0.132222)
          mapView.setRegion(MKCoordinateRegion(center: center, span: span), animated: true)
      }
  }
  
  extension MapViewController: MKMapViewDelegate {
  
      /// - Tag: CreateAnnotationViews
      func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -&gt; MKAnnotationView? {
          guard !annotation.isKind(of: MKUserLocation.self) else {
              // Make a fast exit if the annotation is the `MKUserLocation`, as it's not an annotation view we wish to customize.
              return nil
          }
  
          var annotationView: MKAnnotationView?
  
          if let annotation = annotation as? ShrekAnnotation {
              annotationView = setupShrekAnnotationView(for: annotation, on: mapView)
          } else if let annotation = annotation as? CoffeeAnnotation {
              annotationView = setupCoffeeAnnotationView(for: annotation, on: mapView)
          }
  
          return annotationView
      }
  
      /// - Tag: ConfigureAnnotationViews
      private func setupShrekAnnotationView(for annotation: ShrekAnnotation, on mapView: MKMapView) -&gt; MKAnnotationView {
          let reuseIdentifier = NSStringFromClass(ShrekAnnotation.self)
          let view = mapView.dequeueReusableAnnotationView(withIdentifier: reuseIdentifier, for: annotation)
  
          view.canShowCallout = true
  
          // Provide the annotation view's image.
          let image = #imageLiteral(resourceName: "map-shrek1")
          view.image = image
  
          return view
      }
  
      /// - Tag: ConfigureAnnotationViews
      private func setupCoffeeAnnotationView(for annotation: CoffeeAnnotation, on mapView: MKMapView) -&gt; MKAnnotationView {
          let reuseIdentifier = NSStringFromClass(CoffeeAnnotation.self)
          let view = mapView.dequeueReusableAnnotationView(withIdentifier: reuseIdentifier, for: annotation)
  
          view.canShowCallout = true
  
          // Provide the annotation view's image.
          let image = #imageLiteral(resourceName: "map-cof1")
          view.image = image
  
          return view
      }
  }
  </code></pre>
  
  <p>Apparently the class extension is not being called but I don't know how to fix this. The code that worked before I tried implementing it in my own project is identical. Could I have missed something I should've copied too or can you find the reason for the bug in the code?</p>
  
  <p>Thanks for any help.</p>