简体   繁体   English

SMJobBless和朋友

[英]SMJobBless and friends

i made an App that was submitted to the Mac AppStore. 我制作了一个提交给Mac AppStore的应用程序。 For some reasons, they refused it, because it was installing a helper tool using the SMJobBless API. 由于某些原因,他们拒绝了它,因为它正在使用SMJobBless API安装帮助程序工具。

As this helper tool isn't necessary for most of the App's functionality, i have removed it, and my application got accepted. 由于该帮助程序工具对于大多数应用程序功能不是必需的,因此我已将其删除,并且我的应用程序已被接受。

So right now, i am packaging a standalone installer for the helper tool that would be downloadable on the internet. 因此,现在,我正在打包一个独立的安装程序,用于帮助程序工具,该工具可以从Internet上下载。

However, after i have installed the files in place, the helper tool refuses to run... The helper tool just has a plist that goes into /Library/LaunchDaemons and a binary that goes into /Library/PrivilegedHelperTools. 但是,在我将文件安装到位之后,帮助程序工具拒绝运行...该帮助程序工具只有一个进入/ Library / LaunchDaemons的plist和一个进入/ Library / PrivilegedHelperTools的二进制文件。

Now i'm wondering, what exactly is SMJobBless doing more than moving files into place? 现在我想知道,除了将文件移到适当位置之外,SMJobBless到底在做什么? Is it registering my tool with launchctl? 是否在launchctl中注册了我的工具? i tried various things, to manually add it to launchctl, without success: the helper tool just exits after requesting it's checkin request. 我尝试了各种尝试,将其手动添加到launchctl中,但没有成功:辅助工具仅在请求签入请求后退出。

The helper tool just contains that: 辅助工具仅包含以下内容:

@autoreleasepool {
    launch_data_t       req             = launch_data_new_string(LAUNCH_KEY_CHECKIN);
    launch_data_t       resp            = launch_msg(req); // AT THIS POINT, RESP IS NULL. Why?
    launch_data_t       machData        = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_MACHSERVICES);
    launch_data_t       machPData       = launch_data_dict_lookup(machData, [kHelperBundleName UTF8String]);
    mach_port_t         mp              = launch_data_get_machport(machPData);
    launch_data_free                    (resp);
    launch_data_free                    (req);
    // Prepare connexion.
    NSMachPort          *rp             = [[NSMachPort alloc] initWithMachPort:mp];
    PrivilegedHelperProxy
                        *phProxy        = [[[PrivilegedHelperProxy alloc] init] autorelease];
    NSConnection        *con            = [NSConnection connectionWithReceivePort:rp sendPort:nil];
    [rp release];
    [con setRootObject:phProxy];
    [[NSRunLoop currentRunLoop] run];
}
return                                  EXIT_SUCCESS;

This service was running flawlessly when getting installed via the SMJobBless API, and the root proxy was accessible from within my APP... 通过SMJobBless API进行安装时,该服务可以完美运行,并且可以从我的APP中访问根代理...

So what would be the required steps for my installer to get this helper tool properly working, as it would with calls to the SMJobBless API? 那么,与调用SMJobBless API一样,安装程序如何才能正常使用此帮助程序工具,需要执行哪些步骤?

Thanks, Pierre. 谢谢,皮埃尔。

Solved. 解决了。 The PList entry for the helper tool wasn't including any ProgramArguments (This didn't seem to be an issue with the SMJobBless API). 帮助器工具的PList条目不包含任何ProgramArguments(这似乎与SMJobBless API无关)。 After adding those to the PList, the helper tool can correctly run, and the installer registers it correctly. 将它们添加到PList之后,帮助程序工具可以正确运行,并且安装程序会正确注册它。

Thanks anyways! 不管怎么说,多谢拉! Pierre. 皮埃尔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM