---
title: "init(serviceName:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsxpcconnection/init(servicename:)"
---

# init(serviceName:)

Initializes an NSXPCConnection object to connect to an NSXPCListener object in an XPC service, identified by a service name.

## Declaration

```swift
init(serviceName: String)
```

## Discussion

Discussion XPC services are helper processes that are usually part of your application bundle. The service should use NSXPCListener to wait for new connections.

## See Also

### Creating a connection

- [init(listenerEndpoint:)](foundation/nsxpcconnection/init(listenerendpoint:).md)
- [init(machServiceName:options:)](foundation/nsxpcconnection/init(machservicename:options:).md)
- [NSXPCConnection.Options](foundation/nsxpcconnection/options.md)
