<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCWaitCompletionHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:@T@XCWaitCompletionHandler"
  },
  "title" : "XCWaitCompletionHandler"
}
-->

# XCWaitCompletionHandler

A block the test runner calls when the test fulfills a waiter’s expectations, or when it times out.

```
typealias XCWaitCompletionHandler = ((any Error)?) -> Void
```

## Parameters

`error`

The error the waiter object encountered while waiting, which can be a timeout or a failure. See [`XCTestError.Code`](/documentation/XCTest/XCTestError/Code) for a list of possible errors.

## Discussion

Pass a block with this signature to [`waitForExpectations(timeout:handler:)`](/documentation/XCTest/XCTestCase/waitForExpectations(timeout:handler:)). Your block should handle any errors the waiter object encounters, including a timeout, and should perform assertions when the test fulfills the expectation for the waiter object.

---

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)