Search code examples
c#monocore-locationmonomac

CoreLocation not working with MonoMac


Ok, so I'm trying to use CoreLocation in a mono mac app. After a few attempts at getting it to work with no luck (the .UpdatedLocation event is never raised), I grabbed this sample from the MonoMac repository.

The configuration/use of the CLLocationManager seems pretty straightforward:

locationManager = new CLLocationManager();
locationManager.UpdatedLocation += HandleLocationManagerUpdatedLocation;
locationManager.Failed += HandleLocationManagerFailed;
locationManager.StartUpdatingLocation();

Unfortunately, it seems the results were the same there as the location is never shown:

Where Is My Mac Sample App

So is there some sort of setting on the mac that I need to enable for this to work? CLLocationManager.LocationServicesEnabled is returning true when I check it at runtime.


Solution

  • On Mountain Lion I see the same issue that Joel is seeing. The update never occurs. I created a sample obj-c app and that does work. In the console log I see these errors with the MonoMac app:

    9/16/12 8:06:34.291 AM com.apple.launchd.peruser.501[154]: (com.apple.CoreLocationAgent) Throttling respawn: Will start in 1 seconds
    9/16/12 8:06:35.332 AM CoreLocationAgent[7744]: CodeSigningInforequest for pid=7739 
    9/16/12 8:06:35.333 AM CoreLocationAgent[7744]: getting requirement data failed for pid=7739
    

    But for the obj-c app it looks like:

    9/16/12 8:02:18.143 AM CoreLocationAgent[7674]: locationRequest for pid=7670 message=0
    9/16/12 8:02:20.196 AM CoreLocationAgent[7674]: locationRequest for pid=7670 response=1
    

    I have not determined the cause.