---
title: "xpc_connection_activate(_:)"
framework: xpc
role: symbol
role_heading: Function
path: "xpc/xpc_connection_activate(_:)"
---

# xpc_connection_activate(_:)

Activates a new connection.

## Declaration

```swift
func xpc_connection_activate(_ connection: xpc_connection_t)
```

## Discussion

Discussion Connections start in an inactive state, so you must call xpc_connection_activate(_:) on a connection before it will send or receive any messages. Calling xpc_connection_activate(_:) on an active connection has no effect. Releasing the last reference on an inactive connection that was created with a call to one of the xpc_connection_create functions is undefined. For backward compatibility reasons, xpc_connection_resume(_:) on an inactive and not otherwise suspended XPC connection has the same effect as calling xpc_connection_activate(_:). For new code, using xpc_connection_activate(_:) is preferred.

## See Also

### Life cycle

- [xpc_main(_:)](xpc/xpc_main(_:).md)
- [xpc_connection_suspend(_:)](xpc/xpc_connection_suspend(_:).md)
- [xpc_connection_resume(_:)](xpc/xpc_connection_resume(_:).md)
- [xpc_connection_cancel(_:)](xpc/xpc_connection_cancel(_:).md)
- [xpc_transaction_begin()](xpc/xpc_transaction_begin().md)
- [xpc_transaction_end()](xpc/xpc_transaction_end().md)
- [xpc_connection_copy_invalidation_reason(_:)](xpc/xpc_connection_copy_invalidation_reason(_:).md)
