atnan / SMJobBlessXPC

Apple's SMJobBless sample code, modified to use XPC for app/helper IPC
156 stars 33 forks source link

Error On Mountain Lion #2

Open KingOfBrian opened 12 years ago

KingOfBrian commented 12 years ago

Not sure what this error is, but on mountain lion, I'm getting:

Failed to bless helper. Error: Error Domain=kSMErrorDomainFramework Code=3 "The operation couldn’t be completed. (kSMErrorDomainFramework error 3 - The client and tool did not match requirements.)" UserInfo=0x1001577b0 {NSDescription=The client and tool did not match requirements.}

KingOfBrian commented 12 years ago

I got the XPC part working without privilege escalation by using SMJobSubmit instead of Bless. I realize that this is different than the purpose of this demo app, but it's all I need - XPC Between my background menu item and forground viewer.

- (BOOL)startUserAgentWithLabel:(NSString *)label
                          error:(NSError **)error
{    
    CFDictionaryRef job = SMJobCopyDictionary(kSMDomainUserLaunchd, (CFStringRef)label);
    NSLog(@"Job = %@", (NSDictionary *)job);
    if (job == NULL)
    {
        NSMutableDictionary *plist = [NSMutableDictionary dictionary];
        [plist setObject:@"com.apple.bsd.SMJobBlessHelper" forKey:@"Label"];
        [plist setObject:@"com.apple.bsd.SMJobBlessHelper" forKey:@"Program"];
        [plist setObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
                                                    forKey:@"com.apple.bsd.SMJobBlessHelper"]
                  forKey:@"MachServices"];

        BOOL ok = SMJobSubmit(kSMDomainUserLaunchd, (CFDictionaryRef)plist, NULL, (CFErrorRef *)error);

        return ok;
    }
    return YES;

}
KingOfBrian commented 12 years ago

Actually, I retract that. It got a bit farther but was complaining:

Helper available. Sending request: Hi there, helper service. XPC connection invalid, releasing. Received response: (null).

If I wasn't half asleep, I would of noticed ;)

davidsielert commented 11 years ago

Did you ever figure out the original problem? I got the same exact error myself..

davidsielert commented 11 years ago

Noticed in ASL 11/27/12 6:20:03.581 PM launchdadd[56637]: FAILURE: Code <SecCode 0x7fc0e31005e0 [0x7fff7bed5fd0]> failed requirement (identifier "com.apple.bsd.SMJobBlessApp" and certificate leaf[subject.CN] = "Mac Developer: Nathan de Vries (T3RB9JQ8KZ)") with error "The operation couldn’t be completed. (OSStatus error -67050.)" 11/27/12 6:20:03.581 PM launchdadd[56637]: FAILURE: Code <SecStaticCode 0x7fc0e3600870 [0x7fff7bed5fd0]> failed requirement (identifier "com.apple.bsd.SMJobBlessHelper" and certificate leaf[subject.CN] = "Mac Developer: Nathan de Vries (T3RB9JQ8KZ)") with error "The operation couldn’t be completed. (OSStatus error -67050.)" 11/27/12 6:20:03.582 PM launchdadd[56637]: FAILURE: Job com.apple.bsd.SMJobBlessHelper could not be installed from /Users/david/Library/Developer/Xcode/DerivedData/SMJobBless-eatewdvwqlbljaakruwdobjxswkj/Build/Products/Debug/SMJobBlessApp.app/Contents/Library/LaunchServices/com.apple.bsd.SMJobBlessHelper, reason 3.

davidsielert commented 11 years ago

OK I figured this out .. You have to change the Identity in the info.plist's (as Nathan Says) and also in the build settings.. Nathan Signed with his appstore certificate which we of course do not have so it will not work

socketwiz commented 11 years ago

I changed my identity in both plist files, the one for the app and the one for the helper, and I also changed the code signing identitys in each project. I still get the error:

Failed to bless helper. Error: Error Domain=kSMErrorDomainFramework Code=3 "The operation couldn’t be completed. (kSMErrorDomainFramework error 3 - The client and tool did not match requirements.)" UserInfo=0x101d20130 {NSDescription=The client and tool did not match requirements.}

Any ideas why it might not be working for me?

socketwiz commented 11 years ago

I can't explain why, but this started working for me when I tried to reproduce the problem so I could post another question on StackOverflow. It could be that I moved the project to another directory and did a clean build. I'm not sure. All I know is not only is this project working for me, but I've been able to also replicate in a project of my own.

mmichaa commented 11 years ago

A Product -> Clean (shift+cmd+k) may help ;)

wookiee commented 11 years ago

Is a Mac Developer profile sufficient for this, or must it be an App Store profile?

davidsielert commented 11 years ago

Mac developer will work

On May 3, 2013, at 8:29 AM, "Michael L. Ward" notifications@github.com wrote:

Is a Mac Developer profile sufficient for this, or must it be an App Store profile?

— Reply to this email directly or view it on GitHub.

mmichaa commented 11 years ago

A self-signing certificate suffices. Take a look at: https://developer.apple.com/library/mac/#documentation/security/Conceptual/CodeSigningGuide/Procedures/Procedures.html -- "To use the Certificate Assistant to create a self-signed signing identity"

RudyAramayo commented 11 years ago

Use Developer ID signatures.. apple changed their SMJobBless Samplecode to reflect this based on my DTS response/request

Developer ID will allow the app to run without GateKeeper complaining about an unknown developer...