I have an application that spawns subprocesses. These subprocesses require XPCServices, that are in the same application bundle.
My main application has its executable in
my.app/Contents/MacOS/my
My XPC service sits in my.app/Contents/XPCServices/com.my.service.xpc
When the subprocess resides in my.app/Contents/Resources/mysubprocess
, and the application is being launched, my subprocess can't connect to the XPC service (why not?), but it doesn't show up in the Dock.
If on the other hand the subprocess is in my.app/Contents/MacOS/mysubprocess
the subprocess successfully connects to my XPC service (the main application doesn't need anything from this XPC service), the subprocess suddenly gets an own bouncing icon in the Dock. I guess OS X detects if something is being launched from within *.app/Contents/MacOS/*
and sees it as application.
I obviously need it to work that way, that the subprocess can connect to the XPC service, but that the subprocess stays hidden and doesn't appear in the Dock. I've tried registering LSUIElement and LSBackgroundOnly at runtime to my user defaults, but that didn't do the trick. If i write LSUIElement into the user defaults, my main application doesn't get a main menu, which is also undesired (but in case of LSUIElement being NO
absolutely correct behaviour).
Basically I have two questions:
When I move my subprocess binary outside of my.app/Contents/MacOS/
it can't locate the XPCServices. I find that kinda odd, because the relative path to the service stays the same, if the subprocess would be in my.app/Contents/Resources/
. I also checked [NSBundle mainBundle]
while debugging my subprocess and it had a valid path, even when it was in the Resources
folder. Is there a way to somehow tell my subprocess where it should look for my XPC service?
The other approach would be that I can prevent the subprocess of bouncing in the Dock. My main application needs its icon and menu. So is there a way to specify at runtime that the subprocess won't launch a Dock icon, even if it's in the my.app/Contents/MacOS/
folder?
Thank You