Could not instantiate class named MKMapView

IosIpadMkmapview

Ios Problem Overview


I may be doing something really stupid here as I've done it before and it worked and now...

Created a new iPad project, in the details view I added a MKMapView, added the MapKit.framework to the project, added the property / etc. to the header. Go to run the project and get a SIGABRT with

> **Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate > class named MKMapView'

I found http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial/ but, like I said, I've already added framework. What am I missing?

Ios Solutions


Solution 1 - Ios

I ran into this too, but I was able to get past it by following the instructions of step 2 in your link (thanks, by the way):

> 2. Add the MapKit framework to the project. (Control + Click Frameworks > folder -> Add -> Existing Frameworks)

I just searched for MapKit.framework, added it to the project, and the error went away.

I haven't added any map code yet (although I do have a MapViewDelegate connected in IB), but it's working fine so far!

Solution 2 - Ios

Click on your project to bring the project settings. Under Targets, click your project, select from the upper toolbar "Build Phases". Under "Link binary With Libraries" tab, you will see the list of frameworks included in your project. Click the "+" button and add MapKit library from the shown list to your project.

Solution 3 - Ios

For Xcode 6.1:

  • Select your project
  • In general tab, look for Linked Frameworks and Libraries (last one)
  • Press + button
  • Search MapKit.framework
  • Finally add

Solution 4 - Ios

Easy way!

Works above Xcode version 7.2

As far as I'm concerned selecting the MAPS from capabilities will automatically link your framework to your project all you have to do is check the Maps button in Capabilities -> Maps.

Heres the attached screenshot. Cheers!!

enter image description here

Solution 5 - Ios

For xCode 4.2:

Click on your project name ->targets ->building Phase ->link binary with library 
  -> click on + sign ->select mapKit.framework ->click add

Solution 6 - Ios

I noticed that I was getting this message (on top of the original one mentioned in this post) when I was building and running on the simulator:

> ld: warning: ignoring file > /Users/peter/programming/iPhone/iNspector/MapKit.framework/MapKit, > file was built for unsupported file format which is not the > architecture being linked (i386)

Then I just connected my iPhone, build and ran on the device, and the map worked.

So it seems that the MapKit framework cannot be compiled on the 386 architecture, it needs the device.

Solution 7 - Ios

In regards to @futureshocked's input, I also came across the

> Id: warning: ignoring file /blah.../MapKit, file was built for unsupported file format which is not the architecture being linked (i386)

issue.

**Check to make sure you didn't copy the MapKit framework into your local project directory when you added it to your project. I accidentally did this and XCode was giving me the above error. So I removed it from my project directory (in Finder), recompiled, and everything was normal again.

If you don't have the Framework in your project, go ahead and re-link as stated in the answer above.

Found a good tutorial on getting started with MapKit:
http://www.youtube.com/watch?v=X-3jM24EIGM&feature=related

Solution 8 - Ios

I also received this error when trying to deploy to my 5.1 phone (with XC 4.5), even after changing my deployment target to be 5.1. Looks like the maps update wouldn't fly since I still had Google Maps on my phone. After updating my phone's OS, the exception disappeared.

Solution 9 - Ios

Please import the WebKit at your Build Phases. You need to import the WebKit

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiontg2View Question on Stackoverflow
Solution 1 - IosJoBu1324View Answer on Stackoverflow
Solution 2 - IosAliceView Answer on Stackoverflow
Solution 3 - Iosmarc_aragonesView Answer on Stackoverflow
Solution 4 - IostryKuldeepTanwarView Answer on Stackoverflow
Solution 5 - IosMouzmiSadiqView Answer on Stackoverflow
Solution 6 - IosfutureshockedView Answer on Stackoverflow
Solution 7 - Iosecurb33View Answer on Stackoverflow
Solution 8 - IosRonTorView Answer on Stackoverflow
Solution 9 - IosNaloiko EugeneView Answer on Stackoverflow