Search code examples
iosswiftxcodeerror-handlingfoundation

AVFoundation errors when trying to run app on Xcode9 and Swift 3.2


I have the following problem - I am getting a bunch of errors when I try to run my app using Xcode 9 and Swift 3.2. I have no idea what's wrong and will be very grateful if somebody gives me a hint about it. Thanks in advance!

enter image description here


Solution

  • OK, I finally found what's wrong. The problem is that some of the AVFoundation APIs are temporarily not working.

    AVCaptureDevice.Format.supportedColorSpaces
    AVCaptureDevice.supportedFlashModes
    AVCapturePhotoOutput.availablePhotoPixelFormatTypes
    AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes
    AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes
    

    As a workaround, use the SwiftPrivate versions of these API by prepending each API with double underscore (__). For example, change AVCaptureDevice.Format.supportedColorSpaces to AVCaptureDevice.Format.__supportedColorSpaces.