SMAppService Help!

I'm seeking some help or guidance. I'm attempting to write an app for private use that listens for HID events from a RF reader and responds.

I have a functional app, which has to be launched via sudo, to be able to execute IOHIDManagerOpen(manager, IOOptionBits(kIOHIDOptionsTypeSeizeDevice)) correctly. I'm trying to modify this app, now, to use SMAppService and bypass the need for terminal and sudo, but I'm getting confused at what parts of my code need to be embedded into the helper and how to manage communications between the different components.

I make it to step 8 in https://developer.apple.com/forums/thread/721737 before I start getting lost.

Does anyone know of a functional, SIMPLE, sample app I could take a look at, or a good guide that lays out all parts of an example? Everything I've found gives the bones but no meat.

Answered by DTS Engineer in 792458022

My general advice is that you break problems like this down into parts and then solve each part separately. You already have the HID stuff working in a command-line tool, which is great. That leaves SMAppService and IPC.

On the SMAppService front, I recommend that you start by getting a trivial daemon working. Don’t put your HID code in that, just have the daemon start up and log something. That’ll let you work on the SMAppService code in isolation.

On the IPC front, I generally recommend XPC, and specifically NSXPCConnection. The best way to get started with that is to create a loopback service. See TN3113 Testing and debugging XPC code with an anonymous listener.

Once you have all of the above working independently, you can start integration. Start by integrating your XPC code into your daemon and app, and then go on to integrating your HID code into your daemon.

Share and Enjoy

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

My general advice is that you break problems like this down into parts and then solve each part separately. You already have the HID stuff working in a command-line tool, which is great. That leaves SMAppService and IPC.

On the SMAppService front, I recommend that you start by getting a trivial daemon working. Don’t put your HID code in that, just have the daemon start up and log something. That’ll let you work on the SMAppService code in isolation.

On the IPC front, I generally recommend XPC, and specifically NSXPCConnection. The best way to get started with that is to create a loopback service. See TN3113 Testing and debugging XPC code with an anonymous listener.

Once you have all of the above working independently, you can start integration. Start by integrating your XPC code into your daemon and app, and then go on to integrating your HID code into your daemon.

Share and Enjoy

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

Hey Quinn!

Thank you for that. Unfortunately, i"m still getting hung up on the the IPC/XPC front. I've tried looking into NSXPCConnection, but I'm just not grasping it. Appreciate all the help you do here!

SMAppService Help!
 
 
Q