That sounds like a TCC issue. What does CGPreflightScreenCaptureAccess return?
that returns true and everything works as expected when capturing the screen until I log out. That's when the my frames stay in the background image of the OS and I'm unable to see the password textField but everything else continues to work (mouse and keyboard remote control).
I'm now trying to connect to my Daemon but I'm unable to do it. Here is how I'm testing.
Here is my daemon plist.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.myCompany.myCompanyServer</string>
<key>MachServices</key>
<dict>
<key>com.myCompany.myCompanyServer.xpc</key>
<true/>
</dict>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>path to my exec </string>
<string>service</string>
</array>
<key>QueueDirectories</key>
<array/>
<key>Item 0</key>
<string>path to queue directory</string>
</dict>
</plist>
At this point I'm certain my daemon is up a running. Here is what it'll be my agent running as root. For some reason my interruptionHandler always gets called right away.
final class DaemonConnection {
private var machServiceName = "com.myCompany.myCompanyServer.xpc"
private var daemonConnection: NSXPCConnection
init() {
daemonConnection = NSXPCConnection(machServiceName: machServiceName, options: [.privileged])
daemonConnection.interruptionHandler = interruptionHandler
daemonConnection.invalidationHandler = invalidationHandler
daemonConnection.resume()
}
private func interruptionHandler() {
print("daemon connection was interrrupted")
}
private func invalidationHandler() {
print("daemon conenction was invalidated")
}
}
and here is my daemon code:
private var machServiceName = "com.myCompany.myCompanyServer.xpc."
xpcListener = NSXPCListener(machServiceName: machServiceName)
xpcListener.delegate = self
xpcListener.resume()
then my listener delegate
func listener(_ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool {
Logger.shared.logDebug(logtag, " ******* received new xpc connection request from \(String(describing: newConnection.serviceName)) *****")
return true
}
when I run launchctl print system/myDaemon.plist I see
environment = {
XPC_SERVICE_NAME => com.myCompany.myCompanyServer
}
and I would expect that to be com.myCompany.myCompanyServer.xpc? so it seems I'm missing something? Let me know what you think