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

# XCUIDevice

A proxy that can simulate physical buttons, device orientation, and Siri interaction for an iOS, watchOS, or tvOS device.

```
@MainActor class XCUIDevice
```

## Overview

Use the `XCUIDevice` [`shared`](/documentation/XCUIAutomation/XCUIDevice/shared) instance to perform the following interactions with a simulated iOS, watchOS, or tvOS device during a UI test:

- Press the volume, home, camera, and action buttons.
- Rotate the device.
- Turn the Digital Crown on a watchOS device.
- Determine whether the iOS device supports pointer interaction.
- Activate Siri.

This example shows a test that determines whether the action button is available on the shared device and, if it is, simulates pressing the button:

```swift
@MainActor
func testPressingActionButton() throws {
    let device = XCUIDevice.shared
    try XCTSkipUnless(device.hasHardwareButton(.action),
                  "The device doesn't have an action button.")
    let app = XCUIApplication()
    app.launch()
    device.press(.action)
    // Assert that your app responds correctly.
}
```

`XCUIDevice` is available in iOS, watchOS, and tvOS.

## Topics

### Accessing the current device

[`sharedDevice`](/documentation/XCUIAutomation/XCUIDevice/shared)

The current device.

[`supportsPointerInteraction`](/documentation/XCUIAutomation/XCUIDevice/supportsPointerInteraction)

A Boolean value that indicates if the device supports pointer interaction.

[`supportsHandGestures`](/documentation/XCUIAutomation/XCUIDevice/supportsHandGestures)

A Boolean value that indicates if the device supports hand gestures.

### Interacting with buttons and the Digital Crown

[`-  pressButton:`](/documentation/XCUIAutomation/XCUIDevice/press(_:))

Simulates the user pressing a physical button.

[`-  hasHardwareButton:`](/documentation/XCUIAutomation/XCUIDevice/hasHardwareButton(_:))

Determines whether the device supports the button type you provide.

[`Button`](/documentation/XCUIAutomation/XCUIDevice/Button)

A physical button on an iOS device.

[`-  rotateDigitalCrownByDelta:`](/documentation/XCUIAutomation/XCUIDevice/rotateDigitalCrown(delta:))

Simulates the user rotating the Digital Crown on an Apple Watch by the delta amount.

[`-  rotateDigitalCrownByDelta:withVelocity:`](/documentation/XCUIAutomation/XCUIDevice/rotateDigitalCrown(delta:velocity:))

Simulates the user rotating the Digital Crown on an Apple Watch by the delta amount and speed you provide.

### Performing gestures

[`-  performHandGesture:`](/documentation/XCUIAutomation/XCUIDevice/perform(handGesture:))

[`XCUIDeviceHandGesture`](/documentation/XCUIAutomation/XCUIDeviceHandGesture)

A hand gesture on a watchOS device.

### Rotating and changing location

[`orientation`](/documentation/XCUIAutomation/XCUIDevice/orientation)

The orientation of the device.

[`location`](/documentation/XCUIAutomation/XCUIDevice/location)

The proxy location a test uses to simulate longitude, latitude, and course information for the device.

[`XCUILocation`](/documentation/XCUIAutomation/XCUILocation)

A proxy that simulates a device’s location in terms of its longitude, latitude, and course information.

### Interacting with the OS

[`system`](/documentation/XCUIAutomation/XCUIDevice/system)

An object that provides an interface to OS-specific properties and actions.

[`appearance`](/documentation/XCUIAutomation/XCUIDevice/appearance-swift.property)

The interface style of the device.

[`Appearance`](/documentation/XCUIAutomation/XCUIDevice/Appearance-swift.enum)

Constants that indicate an interface style.

### Interacting with Siri

[`siriService`](/documentation/XCUIAutomation/XCUIDevice/siriService)

An object that represents the Siri interface on the device.

### Deprecated

[`-  init`](/documentation/XCUIAutomation/XCUIDevice/init())

Creates an instance that represents the current device.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)