---
title: NSXPCListener
framework: foundation
role: symbol
role_heading: Class
path: foundation/nsxpclistener
---

# NSXPCListener

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

## Declaration

```swift
class NSXPCListener
```

## Overview

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

## Topics

### Creating a listener

- [init(machServiceName:)](foundation/nsxpclistener/init(machservicename:).md)

### Using standard listeners

- [service()](foundation/nsxpclistener/service().md)
- [anonymous()](foundation/nsxpclistener/anonymous().md)

### Working with a delegate

- [delegate](foundation/nsxpclistener/delegate.md)

### Providing access to clients

- [endpoint](foundation/nsxpclistener/endpoint.md)

### Managing connection state

- [activate()](foundation/nsxpclistener/activate().md)
- [resume()](foundation/nsxpclistener/resume().md)
- [invalidate()](foundation/nsxpclistener/invalidate().md)
- [suspend()](foundation/nsxpclistener/suspend().md)

### Working with code-signing

- [setConnectionCodeSigningRequirement(_:)](foundation/nsxpclistener/setconnectioncodesigningrequirement(_:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### XPC Services

- [NSXPCListenerDelegate](foundation/nsxpclistenerdelegate.md)
- [NSXPCListenerEndpoint](foundation/nsxpclistenerendpoint.md)
