title: iPhone 7+, ios 11.2: Depth data delivery is not supported in the current configuration
body: <p>This bug is driving me mad. I'm trying to produce the absolute minimal code to get <code>AVDepthData</code> from an iPhone 7+ using its DualCam.</p>
  
  <p>I have this code:</p>
  
  <pre>
  <code>
  //
  //  RecorderViewController.swift
  //  ios-recorder-app
  
  
  import UIKit
  import AVFoundation
  
  
  class RecorderViewController: UIViewController {
  
      @IBOutlet weak var previewView: UIView!
  
      @IBAction func onTapTakePhoto(_ sender: Any) {
  
          guard let capturePhotoOutput = self.capturePhotoOutput else { return }
  
          let photoSettings = AVCapturePhotoSettings()
  
          photoSettings.isDepthDataDeliveryEnabled = true //Error
  
          capturePhotoOutput.capturePhoto(with: photoSettings, delegate: self)
  
      }
  
      var session: AVCaptureSession?
      var videoPreviewLayer: AVCaptureVideoPreviewLayer?
      var capturePhotoOutput: AVCapturePhotoOutput?
  
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          AVCaptureDevice.requestAccess(for: .video, completionHandler: { _ in })
  
          let captureDevice = AVCaptureDevice.default(.builtInDualCamera, for: .depthData, position: .back)
  
          do {
              print(captureDevice!)
              let input = try AVCaptureDeviceInput(device: captureDevice!)
  
              self.capturePhotoOutput = AVCapturePhotoOutput()
              self.capturePhotoOutput?.isDepthDataDeliveryEnabled = true //Error
  
              self.session = AVCaptureSession()
              self.session?.addInput(input)
  
              self.videoPreviewLayer = AVCaptureVideoPreviewLayer(session: self.session!)
              self.videoPreviewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill
              self.videoPreviewLayer?.frame = view.layer.bounds
              previewView.layer.addSublayer(self.videoPreviewLayer!)
  
              self.session?.addOutput(self.capturePhotoOutput!)
              self.session?.startRunning()
  
          } catch {
              print(error)
          }
  
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  }
  
  extension RecorderViewController : AVCapturePhotoCaptureDelegate {
  
      func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
          print(photo.depthData)
  
      }
  
  
  }
  </code>
  </pre>
  
  <p>If I comment out the lines that are marked with "Error" the code works as I would expect, and prints <code>nil</code> for <code>depthData</code>.</p>
  
  <p>However, leaving the lines as they are, I get an exception. The error message states: <code>AVCapturePhotoOutput setDepthDataDeliveryEnabled:] Depth data delivery is not supported in the current configuration</code>.</p>
  
  <p>How do I change the "current configuration" so that depth delivery is supported?</p>
  
  <p>I've watched this video: <a href="https://developer.apple.com/videos/play/wwdc2017/507/" rel="nofollow noreferrer">https://developer.apple.com/videos/play/wwdc2017/507/</a> which was helpful, and I believe I've followed the exact steps required to make this work.</p>
  
  <p>Any tips would be gratefully received!</p>