Hi,
I have a sandboxed app with a bundled sandboxed XPC service. When it’s launched, the XPC service registers a repeating XPC activity with the system. The activity’s handler block does get called regularly like I’d expect, but it stops being called once the main app terminates.
What’s the recommended way to fix this issue? Could I have a bundled XPC service double as a launch agent, or would that cause other problems?
it stops being called once the main app terminates.
That’s what I’d expect. launchd
jobs run within a session. In the case of an XPC service bundled in your app [1], that session is created when the app launches and destroyed when the app quits. When the session goes away, there’s no context in which to run your XPC activity.
Could I have a bundled XPC service double as a launch agent, or would that cause other problems?
No. But you could create a launchd
daemon that vends a named XPC endpoint, which should get you where you want to be.
I recommend that you install your agent using SMAppService
.
I recommend that you configure your agent to launch on demand, which allows the system to stop it when it’s idle (no traffic to the named XPC endpoint and no XPC activity running).
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] This is the only valid option for third-party products. See the discussion of the ServiceType
property in the xpcservice.plist
man page.