Encountering error: "Setting device discovery mode to DiscoveryMode_None" when setting up Camera (Swift) : <p>Here is my code setting up a simple camera app</p>

<pre><code>override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    let deviceSession = AVCaptureDeviceDiscoverySession(deviceTypes: [.builtInDualCamera, .builtInTelephotoCamera, .builtInWideAngleCamera], mediaType: AVMediaTypeVideo, position: .unspecified)
    for device in (deviceSession?.devices)!{
        if device.position == AVCaptureDevicePosition.front {
            do {
                currentDevice = device
                let input = try AVCaptureDeviceInput(device: device)
                if captureSession.canAddInput(input){
                    captureSession.addInput(input)

                    if captureSession.canAddOutput(photoOutput){
                        captureSession.addOutput(photoOutput)
                    }

                    if captureSession.canAddOutput(videoOutput){
                        captureSession.addOutput(videoOutput)
                        videoOutput.connection(withMediaType: AVMediaTypeVideo).isVideoMirrored = true
                    }

                    previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
                    previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
                    previewLayer.connection.videoOrientation = .portrait //Change orientation

                    cameraView.layer.addSublayer(previewLayer)
                    cameraView.addSubview(takePictureButton)
                    cameraView.addSubview(takeVideoButton)
                    cameraView.addSubview(saveVideoButton)


                    previewLayer.position = CGPoint(x: self.view.center.x, y: self.view.center.y)
                    previewLayer.bounds = CGRect(x: 100, y: 150, width: self.view.frame.width, height: self.view.frame.height)

                }

                captureSession.startRunning()
            } catch let avError {
                print(avError)
            }
        }
    }
}
</code></pre>

<p>This works fine, but throws this message in the debug window </p>

<pre><code>2018-02-26 20:12:27.699481-0800 FACS[1063:425226] [] &lt;&lt;&lt;&lt;     
AVOutputDeviceDiscoverySession (FigRouteDiscoverer) &gt;&gt;&gt;&gt;  
-[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl    
outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device 
discovery mode to DiscoveryMode_None (client: FACS)
2018-02-26 20:12:27.774719-0800 FACS[1063:425226] [framework]
CUICatalog: Invalid asset name supplied: '(null)'
</code></pre>

<p>The strange part is that when I try to clean up the code above, it still works but now is much slower (by cleanup I mean put things in helper functions). By looking at related posts,  </p>

<p><a href="https://stackoverflow.com/questions/47132877/playing-audio-from-url-give-me-this-log-error-and-stuck-swift">Playing audio from URL give me this log error and stuck .(Swift)</a></p>

<p><a href="https://stackoverflow.com/questions/47438401/avplayer-is-not-playing-in-ios-11">AVPlayer is not playing in iOS 11</a></p>

<p>the only thing I can deduce is that it has something related to IOS 11. How do I fix this error?</p>
