沙盒助手应用程序无法启动正确的父应用程序
我正在使用 本教程将登录项添加到我的应用程序中。大部分工作都按预期进行,我已经成功创建了一个沙盒帮助程序应用程序并将其注册到启动服务中,因此它在登录时按应有的方式启动。
现在的问题是,该教程对于如何从这个帮助应用程序中启动主应用程序包并不是非常具体。它只包括这个:
[[NSWorkspace sharedWorkspace] launchApplication:
@"/Path/To/Main/App/Bundle"];
但是,如果我尝试任何 NSWorkspace 方法来使用完整路径启动应用程序,它就会失败,因为沙箱不允许这样做。
如果我尝试将上述方法的参数设置为我的应用程序名称,它会起作用,但奇怪的是,会启动我的应用程序的旧版本(我将这些存储在我的硬盘上,但它们不在 /Applications 文件夹中,只在我的应用程序的正确版本位于 /Applications 文件夹中)
现在有人知道为什么会发生这种情况吗?或者我该如何解决这个问题?
I'm using this tutorial to add a Login Item to my application. Most of it works as expected, I've managed to create a sandboxed helper app and register it with the launch services, so it is launched on login as it should be.
Now the problem is that the tutorial is not very specific on how you are supposed to launch your main application bundle from within this helper app. It includes only this:
[[NSWorkspace sharedWorkspace] launchApplication:
@"/Path/To/Main/App/Bundle"];
But if I try any NSWorkspace method to launch the application with the full path it fails, because Sandbox does not allow this.
If I try setting the argument of the above method to just my app name, it works, but launches, curiously, an older version of my app (I have these stored on my HDD, but they are not in the /Applications folder, only the correct version of my app is in the /Applications folder)
Does anybody now why this happens, or how could I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现助手应用程序需要可执行文件的路径,而不是捆绑包的路径。
所以如果你给它:
/应用程序/我伟大的应用程序.app
尝试使用:
/Applications/MyGreatApp.app/Contents/MacOS/My Great App
如果您的沙盒应用程序不在“应用程序”文件夹中,则此操作将默默失败,同时记录各种权限错误。
I found that the Helper app needs the path to the executable, not the path to the bundle.
So if you are giving it:
/Applications/My Great App.app
Try using:
/Applications/MyGreatApp.app/Contents/MacOS/My Great App
And if your sandboxed app is not in the Applications folder, this will fail silently, while logging various permissions errors.