You are correct that there isn t much documentation for this. You ll basically write another app, the helper app, which will get installed with SMJobBless(). Not surprisingly,
the tricky part here is the code signing. The least obvious part for me was that the SMAuthorizedClients and SMPrivilegedExecutables entries in the info plist files of each app are dependent on the identity/certificate that you used to sign the app with. There is also a trick with the compiler/linker to getting the info plist file compiled into the helper tool, which will be a single executable file, rather than a bundle.
一旦帮助程序启动并运行,你就必须设计一种与它进行沟通的方法,因为这些程序是两个不同的进程。 XPC 是一个选项,也许是最简单的选项。 XPC 通常用于服务器进程, 但这里使用的只是 XPC 的通信侧面。 它基本上通过两个应用程序之间的词典来回传。 为字典创建标准格式 。 我用的是“ action ”, @“ source ”, 以及 3个不同的动作值 : @“ filemove ”, @“filecopy” 和@ makedirectory 。 这些是我的助手应用程序可以做的3件事情, 必要时我可以轻松地添加更多的东西 。
帮助程序将基本上设置 XPC 连接和事件处理器, 并等待连接和命令。 命令将只是一个字典, 这样您就可以检查相应的密钥/ 值, 并做任何事情 。
我可以提供更多细节和代码 如果你需要更多帮助, 但这个问题已经9个月了 所以我不想浪费时间 告诉你细节,你已经知道了。