My platform contains system wide Daemon based on mixed c++/objective-c code which operated by launchd
according the plist file with the proper configuration reside in /Library/LaunchDaemons/
.
On the other side, it contains UI based application built using storyboard which runs from the background and defined as LaunchAgent
(meaning that it's also operated by launchd
using plist file in /Library/LaunchAgents/
)
Now I wish to establish a uni directional connection between them so that the Daemon can send messages to be displayed by the UI application. the messages can contain strings/numbers or any other displayable data.
I've checked the option using XPC connection and added NSXPCConnection
to my daemon that shares a dedicated protocol with the server implemented in the UI side using NSXPCListener
.
I'd be happy to get reviews and suggestions about my design, especially in the followed aspects
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 ?
thanks
Now I wish to establish a uni directional connection between them so that the Daemon can send messages to be displayed by the UI application.
It didn't work for me. Root process couldn't initialize communication with a user process. But it worked vice versa: if the connection is initiated by UI (you instantiate NSXPCConnection in UI, and a listener in Daemon).