XPC Mach service - Integrate custom framework

Hi,

How do I integrate custom framework into XPC Mach Service and access those functions part of custom framework ?

I have created a XPC Mach service (executable) for providing services to other applications and registered it as launch agent (/Library/LaunchAgents). Service works fine with basic functionalities. I'm able to access services / protocol functions exposed by the Mach Service from another client application and able to retrieve data also from Mach service.

But for certain actions , i need to integrate this XPC Mach service with a custom framework. Integrated in the following way:
  1. Select XPC Mach Service executable in project settings and click on General -> Framework & Libraries

  2. Click on + symbol and specify the custom framework from the list and click on add button.

  3. Once it is added into project, open main.swift and import that framework and access the functions inside the framework.

This works fine and compiler is not showing any errors when I build the project.

When i try to access XPC Mach service function, it doesn't return any value. when i check the XPC status using 'launchctl list' command from the terminal, it shows status code as -6 and no process ID is associated for the service. If i remove the custom framework, it works fine.

What should be the issue? how do i resolve it? can i integrate a custom framework into XPC mach service? This is a common framework used by our other apps. Any limitations???
A launchd agent is a standalone executable. It’s not packaged as a bundle and thus it can’t carry around a framework (that is, you can’t embed a framework within the agent). If you want to use a framework in your agent, you’ll have to install that framework somewhere it can reference it. Traditionally this is /Library/Frameworks.

There are serious downsides to do this, however, in that it makes your installation and upgrade scenarios much more complex. For example, if you upgrade your agent and the new agent uses new features from its framework, you have to upgrade your framework as well.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
XPC Mach service - Integrate custom framework
 
 
Q