@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) }
当我使用Xcode 9 swift 4运行应用程序时,我收到此错误
尝试改变Undefined symbols for architecture x86_64:
“__T0So22AVCapturePhotoSettingsC12AVFoundation01_abC16SwiftNativeTypesACWP”,
referenced from:
__T014vision_app_dev8CameraVCC06didTapD4ViewyyF in CameraVC.o “__T012AVFoundation39_AVCapturePhotoSettingsSwiftNativeTypesPAAE016availablePreviewc11PixelFormatG0Says6UInt32VGfg”,
referenced from:
__T014vision_app_dev8CameraVCC06didTapD4ViewyyF in CameraVC.o ld: symbol(s) not found for architecture x86_64 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
让previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first!
至
让previewPixelType = settings .__ availablePreviewPhotoPixelFormatTypes.first!
*** Apple意外地将一些AVFoundation API外部协议私有化,因此在访问它们的方法之前有2个不受欢迎的_.
资料来源:https://forums.developer.apple.com/thread/86810#259270
资料来源:Try Sample AVCAM from apple found error