There is no answer to this problem, but here is how I approach this:
Both daemon and viewer applications use the same kernel data store to store and retrieve data.
Since sharing the master data repository between processes is not supported (as far as I know), I would have a daemon demonstrating the XPC Service . Instead of opening the master data store itself, the viewer will use NSXPCConnection to access the data through the daemon.
Assuming that the viewer never starts without a daemon, it can use SMLoginItemSetEnabled , as you mentioned in the question, to register the mach service for the daemon, and then connect to that service.
Here is an example code that details the settings here on the Apple website (summary: the daemon should be in App.app/Contents/Library/LoginItems/daemon.bundle.id.app ) and you can also read this blog post , which discusses some additional sandbox requirements (summary: make sure your ID command is in the daemon package identifier).
The daemon should always run when the viewer starts.
The whole set: after registering the daemon using SMLoginItemSetEnabled , it starts (if necessary) when the viewer connects to its XPC service.
Now that the user exits the daemon, the viewer must also stop.
The viewer can use the NSXPCConnection to find out when the daemon is NSXPCConnection down. The daemon can also use SMLoginItemSetEnabled for self-registration before it SMLoginItemSetEnabled so that it does not restart.
I would like to use NSUserDefaults for the basic configuration, can I somehow exchange this data between the daemon and the viewer? Again, both applications will have different package identifiers.
Use the set for this:
// To read or write: NSUserDefaults* suiteDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.example.app.shared"]; [suiteDefaults setObject:[NSDate date] forKey:@"launchTime"]; // Add the suite to -standardUserDefaults to make reading easier: NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults addSuiteNamed:@"com.example.app.shared"];
To work with the sandbox, the viewer and the demon must share a group of applications. You can even use KVO to monitor changes to shared keys.