I created my Device Activity Monitor extension, and then attempted to start monitoring using the code example from the video:
let schedule = DeviceActivitySchedule(
intervalStart: DateComponents(hour: 0, minute: 0),
intervalEnd: DateComponents(hour: 23, minute: 59),
repeats: true
)
let center = DeviceActivityCenter()
do {
try center.startMonitoring(.daily, during: schedule)
} catch {
print(error)
}
The startMonitoring call always fails for me with the same error:
[monitor] Failed to create UsageTrackingAgent proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.UsageTrackingAgent was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.UsageTrackingAgent was invalidated.}
Setting up the extension is a very manual process, so I likely missed a step somewhere, but any ideas on what this error might be indicating?