Cocoa: Sandbox entitlement to launch another application

我只是一个虾纸丫 提交于 2019-12-17 19:48:28

问题


I'm calling

[[NSWorkspace sharedWorkspace] launchApplication:path];

From my sandboxed app, and I'm getting this error in the console:

9/5/11 12:23:12.462 PM lsboxd: refusing to spawn < PATH REDACTED > for 21383 - reason -10826

9/5/11 12:23:12.463 PM App: spawn_via_launchd() failed, errno=54 label=[0x0-0x1994993].MYApp path=< PATH REDACTED > flags=0

9/5/11 12:23:12.464 PM App: LSOpenFromURLSpec() returned -10810 for application < PATH REDACTED > (null).

In other words, I'm clearly getting blocked by the "Launch Services Sandbox Daemon" (lsboxd) which doesn't think app 1 should be launching app 2.

For the record 10826 is "The user does not have permission to launch the application" and then 10810 is "An unknown error has occurred"

Does anyone know of an entitlement for this case?

How can you launch other apps from a sandboxed app (please don't say AppleScript - it's a non-functioning nightmare, especially when called from sandboxed apps or XPC services). The ideal is a way to use the (severely crippled) NSWorkspace from within a sandbox.


回答1:


The parameter of launchApplication: is the application's name (i.e. something like @"Safari"), not its path. That way, it's been working without any special entitlements for me. I don't think you can launch apps at arbitrary paths from a sandboxed app without using PowerBox.



来源:https://stackoverflow.com/questions/7311171/cocoa-sandbox-entitlement-to-launch-another-application

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