Does an OS X executables need to be built in specific way (e.g. no UI, implement certain interfaces) so it can be used as a service? Does this vary by its language (e.g. Objective C, Java) or its implementation (compiled versus script)?


An executable on macOS can be run as a service or application almost regardless of how it is created.

The question to ask is, does the process require access to the WindowServer? The WindowServer is needed to provide a graphical interface.

Graphical User Interface and User Sessions

A process requiring a graphical user interface can be used as a background process or service. Do this by launching the process with launchd from the /Library/LaunchAgents folder.

To present a graphical user interface, the process must be launched within a user session. In launchd terms this means within an Aqua environment.

An example of this would be Power Manager's pmuser process. This process manages tasks specific to the user and handles tasks that the computer wide pmd process can not directly perform.

Computer Wide Processes

A process that does not require a user interface can be launched as a background service with launchd from the /Library/LaunchDaemons folder.

A non-graphical process can exist outside of any user session and thus run even when no-one is logged in.

A computer wide process can not access much of macOS's unique functionality. See Apple's TechNote 2083 and the Living Dangerously section.

  • So an application needs to be launched by /Library/LaunchAgents or /Library/LaunchDaemons, correct? The fact that most process are children (or some ancestor) of launchd seems to suggest this. – craig Dec 14 '18 at 20:05
  • Applications launched by the user will have launchd as the parent. Only daemons, services, and background tasks need to be launched directly from the launchd folders. What are you trying to set up? – Graham Miln Dec 15 '18 at 6:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .