---
title: XCUIDevice
framework: XCUIAutomation
role: symbol
role_heading: Class
platforms: [iOS, iPadOS, Mac Catalyst, macOS, tvOS, visionOS, watchOS, Xcode 16.3+]
path: xctest/xcuidevice
---

# XCUIDevice

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

## Declaration

```swift
@MainActor class XCUIDevice
```

## Overview

Use the `XCUIDevice` [shared](../xcuiautomation/xcuidevice/shared.md) 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

- [shared](../xcuiautomation/xcuidevice/shared.md)
- [supportsPointerInteraction](../xcuiautomation/xcuidevice/supportspointerinteraction.md)
- [supportsHandGestures](../xcuiautomation/xcuidevice/supportshandgestures.md)

### Interacting with buttons and the Digital Crown

- [press(_:)](../xcuiautomation/xcuidevice/press(_:).md)
- [hasHardwareButton(_:)](../xcuiautomation/xcuidevice/hashardwarebutton(_:).md)
- [XCUIDevice.Button](../xcuiautomation/xcuidevice/button.md)
- [rotateDigitalCrown(delta:)](../xcuiautomation/xcuidevice/rotatedigitalcrown(delta:).md)
- [rotateDigitalCrown(delta:velocity:)](../xcuiautomation/xcuidevice/rotatedigitalcrown(delta:velocity:).md)

### Performing gestures

- [perform(handGesture:)](../xcuiautomation/xcuidevice/perform(handgesture:).md)
- [XCUIDeviceHandGesture](../xcuiautomation/xcuidevicehandgesture.md)

### Rotating and changing location

- [orientation](../xcuiautomation/xcuidevice/orientation.md)
- [location](../xcuiautomation/xcuidevice/location.md)
- [XCUILocation](../xcuiautomation/xcuilocation.md)

### Interacting with the OS

- [system](../xcuiautomation/xcuidevice/system.md)
- [appearance](../xcuiautomation/xcuidevice/appearance-swift.property.md)
- [XCUIDevice.Appearance](../xcuiautomation/xcuidevice/appearance-swift.enum.md)

### Interacting with Siri

- [siriService](../xcuiautomation/xcuidevice/siriservice.md)

### Deprecated

- [init()](../xcuiautomation/xcuidevice/init().md)

### Instance Properties

- [voiceOverService](../xcuiautomation/xcuidevice/voiceoverservice.md)

## Relationships

### Inherits From

- NSObject

### Conforms To

- CVarArg
- CustomDebugStringConvertible
- CustomStringConvertible
- Equatable
- Hashable
- NSObjectProtocol
- Sendable

## See Also

### Device simulation

- [XCUISystem](../xcuiautomation/xcuisystem.md)
- [XCUISiriService](../xcuiautomation/xcuisiriservice.md)
