<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 13.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ExtensionKit",
  "identifier" : "/documentation/ExtensionKit/EXHostViewControllerDelegate/hostViewControllerWillDeactivate(_:error:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "ExtensionKit"
    ],
    "preciseIdentifier" : "c:objc(pl)EXHostViewControllerDelegate(im)hostViewControllerWillDeactivate:error:"
  },
  "title" : "hostViewControllerWillDeactivate(_:error:)"
}
-->

# hostViewControllerWillDeactivate(_:error:)

Tells the host that the app extension disconnected and is no longer available.

```
@MainActor optional func hostViewControllerWillDeactivate(_ viewController: EXHostViewController, error: (any Error)?)
```

## Parameters

`viewController`

The host view controller that initiated the connection.

`error`

An error object indicating why the app extension disconnected, or `nil` if the extension exited without issues.

## Discussion

The host view controller calls this method when the app extension exits or when
you change the view controller’s [`configuration`](/documentation/ExtensionKit/EXHostViewController/configuration-swift.property) property.
Use this method to close out the previous connection to the app extension.

---

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)