AVCAM example - Swift Xcode v9

 @objc func didTapCameraView() {
    self.cameraView.isUserInteractionEnabled = false
    self.spinner.isHidden = false
    self.spinner.startAnimating()

    let settings = AVCapturePhotoSettings()
    let previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first!
    let previewFormat = [kCVPixelBufferPixelFormatTypeKey as String: previewPixelType, kCVPixelBufferWidthKey as String: 160, kCVPixelBufferHeightKey as String: 160]

    settings.previewPhotoFormat = previewFormat

    if flashControlState == .off {
        settings.flashMode = .off
    } else {
        settings.flashMode = .on
    }
    cameraOutput.capturePhoto(with: settings, delegate: self)
}

I get this error when I launch the application using Xcode 9 swift 4

Undefined symbols for architecture the x86_64:
"__T0So22AVCapturePhotoSettingsC12AVFoundation01_abC16SwiftNativeTypesACWP", link: __T014vision_app_dev8CameraVCC06didTapD4ViewyyF in CameraVC.o "__T012AVFoundation39_AVCapturePhotoSettingsSwiftNativeTypesPAAE016availablePreviewc11PixelFormatG0Says6UInt32VGfg", link: __T014vision_app_dev8CameraVCC06didTapD4ViewyyF in CameraVC.o ld: symbol (s) could not be found for the architecture x86_64 clang: error: linker command with an exit code of 1 (use -v to view the call)

+4
source share
1 answer

Try to change let previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first!

to

let previewPixelType = settings.__availablePreviewPhotoPixelFormatTypes.first!

*** Apple API AVFoundation, , , 2- undescores _ , .

: https://forums.developer.apple.com/thread/86810#259270

: AVCAM

+1

Source: https://habr.com/ru/post/1684191/


All Articles