func xpc_connection_create_mach_service(_ name: UnsafePointer<Int8>, _ targetq: DispatchQueue?, _ flags: UInt64) -> xpc_connection_t



The name of the remote service with which to connect. The service name must exist in a Mach bootstrap that is accessible to the process and be advertised in a launchd.plist.


The GCD queue to which the event handler block will be submitted. This parameter may be NULL, in which case the connection's target queue will be libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. The target queue may be changed later with a call to xpc_connection_set_target_queue().


Additional attributes with which to create the connection.

Return Value

A new connection object.


If the XPC_CONNECTION_MACH_SERVICE_LISTENER flag is given to this method, then the connection returned will be a listener connection. Otherwise, a peer connection will be returned. See the documentation for xpc_connection_set_event_handler(_:_:) for the semantics of listener connections versus peer connections.

This method will succeed even if the named service does not exist. This is because the Mach namespace is not queried for the service name until the first call to xpc_connection_resume(_:).