我正在XPCServices
上尝试一个简单的示例应用,其中我遵循以下步骤:
第1步:创建了一个示例项目,并添加了名称为XPCServices
的目标HelperProcess
。创建目标时,XCode会自动生成以下文件:
第2步:main.m
在ServiceDelegate
的实施中添加了日志声明:
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
// This method is where the NSXPCListener configures, accepts, and resumes a new incoming NSXPCConnection.
NSLog(@"Log which is never displayed :(");
// Configure the connection.
// First, set the interface that the exported object implements.
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(HelperProcessProtocol)];
// Next, set the object that the connection exports. All messages sent on the connection to this service will be sent to the exported object to handle. The connection retains the exported object.
HelperProcess *exportedObject = [HelperProcess new];
newConnection.exportedObject = exportedObject;
// Resuming the connection allows the system to deliver more incoming messages.
[newConnection resume];
// Returning YES from this method tells the system that you have accepted this connection. If you want to reject the connection for some reason, call -invalidate on the connection and return NO.
return YES;
}
第3步:在AppDelegate
applicationDidFinishLaunching:
以下代码
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
_connectionToService = [[NSXPCConnection alloc] initWithServiceName:@"HelperProcess"];
_connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(HelperProcessProtocol)];
[_connectionToService resume];
}
问题是 -
当我启动应用程序时,没有添加日志 listener:shouldAcceptNewConnection:显示也不是帮助器 进程出现在活动监视器中:(
以下是代码:XPCShootOut
注意: 我在XCode 6.0上尝试此操作
我需要做哪些其他设置才能使其正常工作?请建议。
- 更新 -
我尝试从Apple提交此示例:AppSandboxLoginItemXPCDemo
当我尝试在XCode 6上运行它时,它显示错误消息 - “找不到签名身份”。由于我没有注册的mac开发者帐户,在iDecide和iDecideHelper的构建设置中,我将“代码签名身份”更改为“不代码签名”。
我收到了每个目标的警告:
Code Sign warning: CODE_SIGN_ENTITLEMENTS specified without specifying CODE_SIGN_IDENTITY. It is not possible to add entitlements to a binary without signing it.
这次编译构建时,它按预期工作。
现在我尝试按照其ReadMe.txt文件中指定的步骤进行操作,具体而言,我在示例应用中执行了以下步骤:
第1步:已更新 - 主要应用目标 - >功能选项卡
第2步:更新 - 帮助目标 - >功能选项卡
第3步:已更新 - 帮助目标 - >常规标签 - > Bundle Identifier,为其添加了“XYZ”前缀。
在控制台中运行应用程序时,它显示以下消息:
10/12/14 6:27:42.159 PM xpcd[554]: (null): Code identity[pid: 11875::Devarshi-Kulshreshtha.XPCShootOut (/Users/devarshi/Library/Developer/Xcode/DerivedData/XPCShootOut-aaedwraccpinnndivoaqkujcmhmj/Build/Products/Debug/XPCShootOut.app)] is not in ACL for container: ~/Library/Containers/Devarshi-Kulshreshtha.XPCShootOut/Data -- allowing access.
10/12/14 6:27:43.712 PM appleeventsd[63]: <rdar://problem/11489077> A sandboxed application with pid 11875, "XPCShootOut" checked in with appleeventsd, but its code signature could not be validated ( either because it was corrupt, or could not be read by appleeventsd ) and so it cannot receive AppleEvents targeted by name, bundle id, or signature. Error=ERROR: #100013 { "NSDescription"="SecCodeCopySigningInformation() returned 100013, -." } (handleMessage()/appleEventsD.cp #2072) client-reqs-q
两个应用程序都没有执行其预期的功能,也没有显示listener:shouldAcceptNewConnection:
委托中添加的日志消息。
我很无能为力。如果我遗失任何东西,请建议吗?是否可以在没有注册的mac开发者帐户的情况下使XPC服务示例应用程序正常工作?
答案 0 :(得分:-1)
我认为你可以在没有签名的情况下启动XPC服务。
即使是测试和调试,也需要设置代码符号构建基础结构。
我认为Mac开发者证书是免费的,您不需要付费帐户。