Launch helper from sandboxed application

可紊 提交于 2019-12-04 09:58:40

A viable workaround is to use NSTask to spawn /usr/bin/open and give it the helper app's path:

NSTask *task = [NSTask new];
[task setLaunchPath: @"/usr/bin/open"];
[task setArguments: [NSArray arrayWithObjects: helperPath, nil]];
[task launch];

This runs fine from the sandbox, and appears to be compatible with the Mac App Store Review Guidelines.

Update: On further examination, this technique frequently fails with the error

The application cannot be opened because its executable is missing.

This error does not occur when I've turned off sandboxing. So there must be a better solution...

You can use SMLoginItemSetEnabled. You have to ask user consent once. After all, a helper application launched for the first time with SMLoginItemSetEnabled is automatically launched every time the user logs in.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!