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!