2
votes

I am trying to get user permission in order uninstall an application. In order to get the rights. I am following this article published by Apple.

The article is using this library

#include <ServiceManagement/ServiceManagement.h>

What I am Doing? Github Project: Here

Error

Error Domain=CFErrorDomainLaunchd Code=2 "The operation couldn’t be completed. (CFErrorDomainLaunchd error 2.)

1

1 Answers

5
votes

I've had this problem when trying to use the SMJobBless example (http://developer.apple.com/library/mac/#samplecode/SMJobBless), which is referenced in the article you mentioned.

In my case the reason was that the helper tool that was supposed to be installed by the SMJobBless() function was not located at the expected location (Contents/Library/LaunchServices within the application wrapper).

See the copy files build phase of the SMJobBless example. Once I added a similar build phase to my project, I no longer got the CFErrorDomainLaunchd error 2.