---
title: activate()
framework: xpc
role: symbol
role_heading: Instance Method
path: xpc/xpcsession/activate()
---

# activate()

Activates a session so you can send messages.

## Declaration

```swift
func activate() throws
```

## Discussion

Discussion important: Don’t call activate() on a session that’s already active. If you create an inactive session using the inactive initialization option, you must activate the session before deinitialization. Deinitializing an inactive session causes the process to crash. If activation fails, this method automatically cancels the session and throws a XPCRichError that describes the reason activation failed.

## See Also

### Managing the life cycle

- [setIncomingMessageHandler(_:)](xpc/xpcsession/setincomingmessagehandler(_:)-2ukdh.md)
- [setIncomingMessageHandler(_:)](xpc/xpcsession/setincomingmessagehandler(_:)-5lu26.md)
- [setIncomingMessageHandler(_:)](xpc/xpcsession/setincomingmessagehandler(_:)-75ou9.md)
- [cancel(reason:)](xpc/xpcsession/cancel(reason:).md)
- [setCancellationHandler(_:)](xpc/xpcsession/setcancellationhandler(_:).md)
