6

I wrote a simple program, which uses the Cocoa location services to get the user's current position. It works without a problem on a MacBook Pro. However, it does not on a MacBook Air.

I am left with a Operation could not be completed. (kCLErrorDomain error 1.) code, and there's many things I have already tried to fix it (e.g. setting permissions). Upon ticking the checkbox for the application in the privacy settings to enable the location services for the application, it disappears as soon as I launch the application.

To initialize the services I use startUpdatingLocation method of the CLLocationManager class.

Is there any way to solve the issue?

Kara
  • 6,115
  • 16
  • 50
  • 57
az4dan
  • 651
  • 2
  • 10
  • 30

2 Answers2

2

kCLErrorDomain error 1 means that you have been denied access to location services. Most likely, they have been disabled. See disabling location services. If you go to System Preferences -> Security -> Privacy, there's an Enable Location Services box you can check off. Also, the class method authorizationStatus returns the status of your current access to location services. It's state is defined as the following enum:

typedef enum {
   kCLAuthorizationStatusNotDetermined = 0, //user hasn't allowed/denied
   kCLAuthorizationStatusRestricted, //app level restriction, cannot be lifted by user
   kCLAuthorizationStatusDenied, //explicit user denial, or disabled in settings
   kCLAuthorizationStatusAuthorized //self explanitory
} CLAuthorizationStatus;

Hope that helps you in some way. My only advice other than that, since I haven't used location services myself, is you read through the documentation and hopefully find something that helps.

Metabble
  • 11,773
  • 1
  • 16
  • 29
2

The answer is trivial - I forgot to set permissions on the executable file which is ran by a plist file in /Library/LaunchDaemons/. A simple chmod 007 solves the problem.

az4dan
  • 651
  • 2
  • 10
  • 30