<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureDevice/lockForConfiguration()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureDevice(im)lockForConfiguration:"
  },
  "title" : "lockForConfiguration()"
}
-->

# lockForConfiguration()

Requests exclusive access to configure device hardware properties.

```
func lockForConfiguration() throws
```

## Discussion

To set hardware properties on a capture device, such as the [`focusMode`](/documentation/AVFoundation/AVCaptureDevice/focusMode-swift.property) and [`exposureMode`](/documentation/AVFoundation/AVCaptureDevice/exposureMode-swift.property), your app must first acquire a lock on the device. Only hold the device lock if your app requires settable device properties to remain unchanged. Holding the device lock unnecessarily may degrade capture quality in other apps sharing the device.

---

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)