1
votes

I'm working on a Mac OS X service that is managed as a launch daemon. It does not have any GUI, but it is structured as a Cocoa app run with NSApplicationMain.

It seems like even though there is no GUI, there is a problem - everything works fine when started via launchctl in a terminal window, but on system reboot while a process is started I've determined that once NSApplicationMain() is called the process gets stuck. The app delegate method applicationDidFinishLaunching: is never invoked (which is where we initialize the service). There's also no error logged and NSApplicationMain() does not return.

I've combed through the Launch Services docs but I don't see any mention of this issue, nor have I found any information that says a non-GUI NSApplication runtime requires a login or window server to be present.

Anyone have experience with this, know a common gotcha or have a definitive answer whether it's possible to have a non-GUI NSApplication-based launchd service start at boot time?

1

1 Answers

1
votes

It looks like this is related to Bootstrap namespace issues and probably falls under this already-asked question (which for some reason did not turn up in results when I searched stackoverflow for related terms)

Drawbacks of building a background-only COCOA app as a launch daemon?