我正在开发一个 MacOS 应用程序,我试图将 IOSurface 从 XPC 服务发送到客户端应用程序(与 XPC 服务在同一个项目中),但我显然缺少一些东西。我收到以下错误:
Exception: Attempt to decode an xpc type but whitelist does not specify an XPC type '<no key>'.
整个错误文本如下:
2021-03-10 12:00:42.014421+0100 My Project[82813:1358040] [xpc.exceptions]
<NSXPCConnection: 0x600001aae6c0> connection on anonymousListener or serviceListener from pid 82827:
Exception caught during decoding of received selector publishNewFrame:, dropping incoming message.
Exception: Exception while decoding argument 0 (#2 of invocation):
Exception: Attempt to decode an xpc type but whitelist does not specify an XPC type '<no key>'.
我正在使用以下代码发送表面:
guard let connection = processConnection else {
print("Process is not available")
return
}
let process = connection.remoteObjectProxyWithErrorHandler {
error in print("remote proxy error: ", error)
} as! MyProtocol
let XPCSurfaceRef = IOSurfaceCreateXPCObject(unsafeBitCast(surface, to: IOSurfaceRef.self))
process.publishNewFrame(XPCSurfaceRef)
议定书:
@objc public protocol MyProtocol: NSObjectProtocol {
func publishNewFrame(_ XPCSurfaceRef: xpc_object_t)
}
在客户端进程上:
func publishNewFrame(_ XPCSurfaceRef: xpc_object_t) {
let surfaceRef = IOSurfaceLookupFromXPCObject(XPCSurfaceRef)
}
我不知道如何继续。我不清楚我究竟需要将什么列入白名单,或者如何去做。原则上,IOSurface 是 XPC 中支持的类型,所以我知道它应该可以工作。