2 Replies
      Latest reply: Feb 3, 2017 3:15 PM by BoilerLA RSS
      BoilerLA Level 1 Level 1 (0 points)



        I'd like to create a background service (daemon) that is launched periodically so that it can perform some basic periodic tasks when the machine has spare cycles. Ideally we'd use the xpc_activity APIs, and Quinn has posted before that "XPC activity does not require the job to be loaded all the time.". https://forums.developer.apple.com/thread/23361


        But what I can't tell is if by job, it's meant a launchd daemon that is created using a launchd.plist(5). That man page has no reference to any way to use xpc_activity. We could use the com.apple.xpc.activity key in our launchd.plist but there's no documentation on that key, nor do I know if it's even "public".


        We could have a tool that is launched once, calls xpc_activity to register itself, and then exits--but then the service lifecycle gets more hazy when we want to unregister said service.

        • Re: Launchd XPC activity (com.apple.xpc.activity)
          eskimo Apple Staff Apple Staff (6,675 points)

          launchd daemons can use XPC activity just fine; XPC activity will start the daemon when it’s time to run the activity.  The daemon will, however, have to run one in order to register the activity.  The launchd property list keys for statically declaring activities are not documented for third-party developers, alas.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"