<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/XPCSession/activate()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "s:3XPC10XPCSessionC8activateyyKF"
  },
  "title" : "activate()"
}
-->

# activate()

Activates a session so you can send messages.

```
func activate() throws
```

## Discussion

> Important:
> Don’t call ``doc://com.apple.xpc/documentation/XPC/XPCSession/activate()`` on a session that’s already active.

If you create an inactive session using the [`inactive`](/documentation/XPC/XPCSession/InitializationOptions/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`](/documentation/XPC/XPCRichError) that describes the reason activation failed.

---

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)