<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.8.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSXPCListener",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXPCListener"
  },
  "title" : "NSXPCListener"
}
-->

# NSXPCListener

A listener that waits for new incoming connections, configures them, and accepts or rejects them.

```
class NSXPCListener
```

## Overview

Each XPC service, launchd agent, or launchd daemon typically has at least one [`NSXPCListener`](/documentation/Foundation/NSXPCListener) object that listens for connections to a specified service name. Each listener must have a delegate that conforms to the [`NSXPCListenerDelegate`](/documentation/Foundation/NSXPCListenerDelegate) protocol. When the listener receives a new connection request, it creates a new [`NSXPCConnection`](/documentation/Foundation/NSXPCConnection) object, then asks the delegate to inspect, configure, and resume the connection object by calling the delegate’s [`listener(_:shouldAcceptNewConnection:)`](/documentation/Foundation/NSXPCListenerDelegate/listener(_:shouldAcceptNewConnection:)) method.

## Topics

### Creating a listener

[`init(machServiceName:)`](/documentation/Foundation/NSXPCListener/init(machServiceName:))

Initializes a listener in a LaunchAgent or LaunchDaemon which has a name advertised in a `launchd.plist` file.

### Using standard listeners

[`service()`](/documentation/Foundation/NSXPCListener/service())

Returns the singleton listener used to listen for incoming connections in an XPC service.

[`anonymous()`](/documentation/Foundation/NSXPCListener/anonymous())

Returns a new anonymous listener connection.

### Working with a delegate

[`delegate`](/documentation/Foundation/NSXPCListener/delegate)

The delegate for the listener.

### Providing access to clients

[`endpoint`](/documentation/Foundation/NSXPCListener/endpoint)

Returns an endpoint object that may be sent over an existing connection.

### Managing connection state

[`activate()`](/documentation/Foundation/NSXPCListener/activate())

Activates the listener.

[`resume()`](/documentation/Foundation/NSXPCListener/resume())

Starts processing of incoming requests.

[`invalidate()`](/documentation/Foundation/NSXPCListener/invalidate())

Invalidates the listener.

[`suspend()`](/documentation/Foundation/NSXPCListener/suspend())

Suspends the listener.

### Working with code-signing

[`setConnectionCodeSigningRequirement(_:)`](/documentation/Foundation/NSXPCListener/setConnectionCodeSigningRequirement(_:))

Sets the code signing requirement for connections to this listener.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)