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

# location

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

```
var location: XCUILocation? { get set }
```

## Discussion

Use this property to provide a proxy location to simulate longitude, latitude, and course information for the device. If you don’t provide a proxy location, a test uses the physical location of the device that <doc://com.apple.documentation/documentation/CoreLocation> provides. The example below sets the device’s proxy location:

```swift
// A device location that wraps a CLLocation object from Core Location.
let location = XCUILocation(location: CLLocation(
      latitude: 37.050835,
      longitude: -122.070831))

// Sets the device's proxy location.
XCUIDevice.shared.location = location
```

Set the property once in your test fixture’s setup or intialization code to set a proxy location for all the test methods in that fixture.

---

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)