<!--
{
  "availability" : [
    "Xcode: 16.3.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "XCUIAutomation",
  "identifier" : "/documentation/XCUIAutomation/XCUIApplication/activate()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XCUIAutomation"
    ],
    "preciseIdentifier" : "c:objc(cs)XCUIApplication(im)activate"
  },
  "title" : "activate()"
}
-->

# activate()

Activates the application.

```
func activate()
```

## Discussion

This call is synchronous. The application is in a state ready to handle events when this method returns.

If the application isn’t running prior to calling [`activate()`](/documentation/XCUIAutomation/XCUIApplication/activate()), it launches automatically.

If the application previously launched via [`launch()`](/documentation/XCUIAutomation/XCUIApplication/launch()), the system supplies the launch arguments and environment variables from the original call to [`launch()`](/documentation/XCUIAutomation/XCUIApplication/launch()) again.

Unlike [`launch()`](/documentation/XCUIAutomation/XCUIApplication/launch()), a call to [`activate()`](/documentation/XCUIAutomation/XCUIApplication/activate()) doesn’t terminate the existing instance if the application is already running.

The system reports any failure in the activation or launch sequence as a test failure and the test is halted at that point.

---

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)