Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKMapRectMake in Swift causes linker error when compiling

Using MKMapRectMake to create MKMapRect causes compiling error as below:

This is my code:

    var lat = 37.33072
    var lon = -122.029674
    var loc = CLLocationCoordinate2D(latitude: lat, longitude: lon)
    var point = MKMapPointForCoordinate(loc)

    var flyTo = MKMapRectMake(point.x, point.y, 0, 0);

and this is the error from the compiler:

Undefined symbols for architecture i386:
  "_MKMapPointMake", referenced from:
      _MKMapRectMake in ViewController.o
  "_MKMapSizeMake", referenced from:
      _MKMapRectMake in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

My work-around for this is create MKMapRect using the origin and size parameters. Note that I have added MKMapKit to the linked libraries in Build Phases

Is there anyone encounter the same issue and how you fix this?

like image 411
tala9999 Avatar asked Jul 17 '14 11:07

tala9999


1 Answers

Work around it with a utility function:

func myMKMapRect(x: Double, y:Double, w:Double, h:Double) -> MKMapRect {
    return MKMapRect(origin:MKMapPoint(x:x, y:y), size:MKMapSize(width:w, height:h))
}

And file a bug report with Apple, of course.

like image 106
matt Avatar answered Oct 10 '22 16:10

matt