Still a problem five years later. For example, https://developer.apple.com/documentation/os/os_log does not state that which headers I need to include. In case you're wondering, it's "os/log.h".
Post
Replies
Boosts
Views
Activity
That’s interesting, but there are definitely circumstances where folks get mislead by Xcode’s behaviour.
Agreed, and I definitely wouldn't be surprised if it was something weird with Xcode. Though in the same man page:
If the service name for the connection is not present in your launchd.plist's MachServices dictionary, your listener connection's event
handler will receive the XPC_ERROR_CONNECTION_INVALID error, as XPC disallows ad-hoc service name registrations.
Which is the behavior I'm seeing. Though for some reason I also get an EXC_BAD_INSTRUCTION upon calling xpc_connection_resume.
Are you trying to debug the XPC aspects of your code? If so, I recommend that you do this in a single process using an anonymous listener. See TN3113 Testing and debugging XPC code with an anonymous listener.
At first, I wasn't sure how this would apply to me since you can't create anonymous listeners with xpc_connection_create_mach_service, but upon re-reading I realize that I could have replaced the listener connection with xpc_connection_create(NULL, ... following the techniques here, and that does the trick! Some refactoring is definitely in order.
While this doesn't explain dynamic name registration, it does ultimately resolve the issue I'm having. Thanks as always, Quinn!
Thanks for the response! Your write-up provides a lot of great foundational understanding of XPC, and I appreciate the alternatives it provides. I'm not sure how "The Xcode Gotcha" section provides an answer to the question though. In fact, running xpc_connection_create_mach_service does not work in a debug environment since the provided name is not found within the bootstrap namespace.
I'm in the kind-of-opposite scenario basically: The app-to-app communication works normally because the listener is a launchd service (with the appropriate names filled in the MachService section of its info.plist file to allow clients to connect to it). However, I'm attempting to debug it by writing up a small "demo" program where I can easily debug and run the XPC listener code. The code calls xpc_connection_create_mach_service, but doesn't have any MachService names to work with, and a subsequent call to xpc_connection_resume causes an irrecoverable failure.
Shoot, I misnamed the thread. It should have been "Allowing dynamic name registration ..."
Unfortunately, that is the situation I am trying to avoid. I'm putting it lightly when I say that it's unfortunate that we have to go to such lengths to develop older SDKs. Appreciate the input, though!
I am trying to maintain a KEXT as we still provide support for users on Catalina, but the code will not compile under the latest SDK as it does not contain many essential functions and structs from headers inside <security>.
See here for agx's answer to this.
Unfortunate to hear, but that makes sense. Thanks!
Unfortunately, it is an endpoint security sysex. Sorry for the late response! Just got back from vacation.