Can helper application launch XPCService that embedded in its bundle?

Hi, I have an application, it has a helper application in its bundle. After the application starts to run, it will launch the helper application process. The helper application process will load a XPCService embedded in its bundle by launchd. But I got an error which is

 Error Domain=NSOSStatusErrorDomain Code=-10811 "kLSNotAnApplicationErr: Item needs to be an application, but is not" UserInfo={_LSLine=175, _LSFunction=_LSFindBundleWithInfo_NoIOFiltered}

How can the helper application launch a XPCService embedded in its bundle? Or the XPCService can only be launched in main application?

Thanks

Answered by jingliu1 in 789042022

By spawn a child process.

I figured out why this happens. It is because when launching the XPCService, during dyld, there was an error, it can not locate a lib file, so it crashed. After setting the rpath of XPCService, it can be launched successfully.

The error message confused me.

Thanks a lot.

By the way, does it matter that starts the helper application by spawn a child process or using NSWorkspace? Which one do you suggest?

How are you starting this “helper application”? By spawn a child process? Or by launching it with NSWorkspace?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

By spawn a child process.

I figured out why this happens. It is because when launching the XPCService, during dyld, there was an error, it can not locate a lib file, so it crashed. After setting the rpath of XPCService, it can be launched successfully.

The error message confused me.

Thanks a lot.

By the way, does it matter that starts the helper application by spawn a child process or using NSWorkspace? Which one do you suggest?

Which one do you suggest?

There isn’t a single answer to that; it very much depends on the context.

In this case I was asking the question because I’m certain that the NSWorkspace approach doesn’t interfere with XPC service activation. For the spawn approach, I was less than 100% confident, so if that’d been your answer I would’ve run a test to confirm that it works.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Can helper application launch XPCService that embedded in its bundle?
 
 
Q