<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/XPC_ACTIVITY_PREVENT_DEVICE_SLEEP",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "c:@XPC_ACTIVITY_PREVENT_DEVICE_SLEEP"
  },
  "title" : "XPC_ACTIVITY_PREVENT_DEVICE_SLEEP"
}
-->

# XPC_ACTIVITY_PREVENT_DEVICE_SLEEP

A Boolean that indicates whether the activity prevents the system from sleeping while on battery power.

```
let XPC_ACTIVITY_PREVENT_DEVICE_SLEEP: UnsafePointer<CChar>
```

## Discussion

When set to `true`, the activity scheduler takes the necessary power assertions to keep the device awake, excluding the screen. Only set this property for activities that perform critical system functions, and that system sleep can’t interrupt. Note that setting this property can affect battery life.

---

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)