【发布时间】:2017-12-28 07:12:07
【问题描述】:
我的平台包含基于混合 c++/objective-c 代码的系统范围守护程序,由 launchd 根据位于 /Library/LaunchDaemons/ 的正确配置的 plist 文件操作。
另一方面,它包含使用故事板构建的基于 UI 的应用程序,该应用程序从后台运行并定义为 LaunchAgent(这意味着它也由 launchd 使用 /Library/LaunchAgents/ 中的 plist 文件操作)
现在我希望在它们之间建立单向连接,以便守护程序可以发送消息以供 UI 应用程序显示。消息可以包含字符串/数字或任何其他可显示的数据。
我检查了使用 XPC 连接的选项并将NSXPCConnection 添加到我的守护程序中,该守护程序与使用NSXPCListener 在 UI 端实现的服务器共享一个专用协议。
我很乐意收到关于我的设计的评论和建议,尤其是在以下方面
1. Should I implement the UI as launchAgent
(I need to support multi-users, meaning that the daemon can send
different messages to each UI instance per user)
.
2. should I consider using dedicated `XPC service`.
Seems like Xcode has option to create XPC service,
but I don't know how should I "attach" the UI code inside ...
.
3. is it possible to have XPC client which runs objective-c
code while the XPC listener will run on swift code ?
谢谢
【问题讨论】:
标签: ios objective-c xpc