2

Im following a tutorial on how to work with MapKit and I am having trouble getting past the first few steps of the tutorial. I have checked other tutorials and they all have the exact same initial steps.

  1. I place a Map Kit View onto my view controller.
  2. I add: import MapKit.
  3. I add the MapKit framework to my project.
  4. I add an outlet to my view controller.

But I get a warning that ViewController is part of module Mapkit and ignoring MapKit

And then I get an error: use of undeclared type MKMapView - which is most likely caused by MapKit not being imported.

Here's a screen shot of the errors and the code:

enter image description here

I believe I am following the tutorial steps correctly.

Any idea whats Im doing wrong?

Bingo
  • 375
  • 6
  • 17

3 Answers3

11

My guess here is that you called your application MapKit and you are seeing a collision with the actual MapKit framework because the modules have the same name.

Either:

  • create a new project

or

  • adjust the module name build setting (Product Build Name) to avoid a conflict.
Seán Labastille
  • 712
  • 7
  • 17
  • 2
    yep - this was it - I had just realised this myself and came back here to update my post and saw that you had already posted the correct answer :) – Bingo Nov 10 '15 at 12:09
5

Try this, it worked for me.

import UIKit
import MapKit

class ViewController: UIViewController {

    @IBOutlet weak var map: MKMapView!
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

Apart of the weak reference and the syntax issues I would suggest you to check your Project name - the name might clashes with the iOS library! This issue happened to me in the past - check this out If it doesn't work for you let me know

Gal Marom
  • 8,499
  • 1
  • 17
  • 19
0
  1. Restart Xcode
  2. Clean the code
  3. Add MpKit framework.