我有一个沙盒应用程序。我需要它在每次启动时启动一个辅助应用程序(从主应用程序的包中)。然而,这种失败:从沙盒应用程序启动助手
NSError *error;
[[NSWorkspace sharedWorkspace] launchApplicationAtURL:helperURL
options:NSWorkspaceLaunchDefault
configuration:nil
error:&error];
的错误是:
The application “Helper” could not be launched because it is corrupt., NSUnderlyingError=0x10214c700 "The operation couldn’t be completed. (OSStatus error -10827.)"}
现在,错误是误导性的,因为如果我禁用沙盒授权的应用程序启动的罚款。显然这是一个错误,据报道here。
我的问题是:是否有解决方法?
我可以用SMLoginItemSetEnabled
,描述here:
Pass
true
to start the helper application immediately and indicate that it should be started every time the user logs in. Passfalse
to terminate the helper application and indicate that it should no longer be launched when the user logs in.
但是,我不能使用这个API,而不要求用户第一,因为应用商店审查指南2.26:
Apps that are set to auto-launch or to have other code automatically run at startup or login without user consent will be rejected
因此,使用此解决方法意味着询问用户“每次登录时启动助手都可以?如果不是,则不能使用此应用程序!”显然,这不是理想......
不确定这是否与rdar:// 10934199相关,因为launchApplicationAtURL在沙箱下失败,即使它尝试的应用程序启动已由用户手动启动 – valexa 2012-05-08 19:34:07
您是否可以获得安装用户启动代理的权限,该代理将检查您的应用是否正在运行并启动帮助程序? – Colin 2012-07-18 19:01:55