我正在尝试通过SMJobBless安装一个帮助工具,我得到了以下错误,
Error Domain=CFErrorDomainLaunchd Code=8“无法完成操作。(CFErrorDomainLaunchd错误8。)
我验证了代码符号、应用程序的plist和辅助工具,在launchServices中复制了该工具,还链接了plist。
有谁能帮帮我吗?
谢谢,
发布于 2015-06-24 19:03:57
验证以下内容:
1.Code
- (BOOL)blessHelperWithLabel:(NSString *)label
error:(NSError **)error {
BOOL result = NO;
AuthorizationItem authItem = { kSMRightBlessPrivilegedHelper, 0, NULL, 0 };
AuthorizationRights authRights = { 1, &authItem };
AuthorizationFlags flags = kAuthorizationFlagDefaults |
kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights;
AuthorizationRef authRef = NULL;
/* Obtain the right to install privileged helper tools (kSMRightBlessPrivilegedHelper). */
OSStatus status = AuthorizationCreate(&authRights, kAuthorizationEmptyEnvironment, flags, &authRef);
if (status != errAuthorizationSuccess) {
NSLog(@"%@", [NSString stringWithFormat:@"Failed to create AuthorizationRef. Error code: %d", (int)status]);
} else {
/* This does all the work of verifying the helper tool against the application
* and vice-versa. Once verification has passed, the embedded launchd.plist
* is extracted and placed in /Library/LaunchDaemons and then loaded. The
* executable is placed in /Library/PrivilegedHelperTools.
*/
result = SMJobBless(kSMDomainSystemLaunchd, (CFStringRef)label, authRef, (CFErrorRef *)error);
}
return result;
}2.info.plist(主应用)中安装后拥有的工具字段
helper bundle : identifier <Helper Bundle Identifier> and certificate leaf[subject.CN] = "Developer ID Application: xxxxx (YYXSFDHZ6W)"3.允许客户端在helper info.plist中添加和删除工具字段。
item 0 : identifier <Main App Bundle Identifier> and certificate leaf[subject.CN] = "Developer ID Application: xxxxxx (YYXSFDHZ6W)"4.检查xxxxHelperTool-Launchd.plist中的MachServices文件。它应该是
helper tool bundle : YES发布于 2018-08-18 06:26:48
在SMJobBless示例代码(否则将被取代)中找到工具SMJobBlessUtil.py:https://developer.apple.com/library/archive/samplecode/SMJobBless/Introduction/Intro.html
注意: SMJobBless是祝福工作的正确方式。旧方法AuthorizationExecuteWithPrivileges已被弃用,并将在不久的将来被积极避免。不推荐使用"SMJobBless“示例代码,因为下面的示例代码在几乎所有方面都更好。
好的,获取该工具,现在获取当前示例代码:https://developer.apple.com/library/archive/samplecode/EvenBetterAuthorizationSample/Introduction/Intro.html
使用SMJobBlessUtil.py脚本验证和/或设置主程序和帮助器中的Info.plist内容。
发布于 2019-04-24 08:08:16
你可以使用SMJobBlessUtil.py来检查你的应用程序;也许它会出现像dump malformed这样的错误描述;1、
2、然后你可以比较示例代码的项目设置,找到帮助器目标other linker flags,看看你是否应该这样设置。
https://stackoverflow.com/questions/31020919
复制相似问题