问题
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