6

Of course I googled and used the search within stackoverflow. I found some similar discussions:

Could not instantiate class named MKMapView

http://forums.bignerdranch.com/viewtopic.php?f=49&t=490

NSInvalidUnarchiveOperationException: cannot decode object of class (UITableViewCellContentView)

... and lots of copies of that :)

However, I am not using SDK 3.2 but 5.0 (one of the linked discussions suggest it was an error in some beta version of SDK 3.2).

The other discussions and answers suggest that the framework MapKit were not included properly. I tried to include it several ways, following those instructions.

I am still getting this error. It is thown on

    [super loadView];

within my own view controller's

- (void)loadView {

method. The view itself is build within IB. Beside other items is has an MKMapView.

I am using MKMapView in two of my xcode projects. Both were started in xcode 3.2 and now migrated to xcode 4. Within one of the projects the code works fine and in the other one I get this runtime error. I did not identify any significant difference between these projects' setups that could explain this diffrent behaviour to me.

A current workaround is to take off any code (and IB item) that is relatd to a Map View. But in the end I'd rather include that map view because it does serve a purpose :)

Any suggestion is appreciated.

Hermann

Community
  • 1
  • 1
Hermann Klecker
  • 14,039
  • 5
  • 48
  • 71

2 Answers2

8

Go to your target settings - not project level but target level. Click on Build Phases, then expand Link Binary with Libraries. Ensure that MapKit.framework is listed and add it if not.

TomSwift
  • 39,369
  • 12
  • 121
  • 149
  • Thanks. Yes it was included for all targets. Whatever that was - finally I started a new xcode project from scratch, copied all source files and setup all configuration files from scratch (just to be save) and included all required frameworks. Eventually that worked. By doing so I took the chance and converted my project ot ARC which was worth the effort. – Hermann Klecker Mar 16 '12 at 16:48
  • Frankly the answer did not work for me at that time. Therefore I cannot accept it. However, I am glad that it helps others who have a similar problem and find my question. In my case I still assume that something went wrong in the migration of the project. I had to re-start the project from scratch (for other reasons) and copy all soucres over to the new project. By doing so this issue was solved too. – Hermann Klecker Jul 05 '12 at 14:26
0

Using Xcode 7.2 adding Framework can be done in 3 ways.

1. Under Targets Select Project -> Click on General Tab -> Expand Linked Frameworks with Libraries -> Click on + icon -> Search For MapKit -> Click on Add.

2. Under Targets Select Project -> Click on Capabilities -> Under Maps -> Click On Switch Button.

3. Under Targets Select Project -> Click on Build Phases -> Expand Linked Frameworks with Libraries -> Click on + icon -> Search For MapKit -> Click on Add.

Ashok R
  • 19,892
  • 8
  • 68
  • 68