当我尝试使用 Xcode Version 9.0 beta 5 (9M202q) 示例 AVCAM swift 时。我发现了错误。
Undefined symbols for architecture x86_64:
"__T0So22AVCapturePhotoSettingsC12AVFoundation01_abC16SwiftNativeTypesACWP", referenced from: __T05AVCam20CameraViewControllerC12capturePhoto33_F53A4CF98D799BDDCA6C04BA14C549A1LLySo8UIButtonCFyycfU_ in CameraViewController.o
"__T012AVFoundation39_AVCapturePhotoSettingsSwiftNativeTypesPAAE016availablePreviewc11PixelFormatG0Says6UInt32VGfg", referenced from: __T05AVCam20CameraViewControllerC12capturePhoto33_F53A4CF98D799BDDCA6C04BA14C549A1LLySo8UIButtonCFyycfU_ in CameraViewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
问题是什么?以及如何解决这个问题?
最佳答案
2017 年 9 月 15 日更新:
苹果官方回应:
Our apologies. For apps using Swift 3.2 or Swift 4.0, several AVFoundation capture APIs (public extensions on external protocol) were inadvertently marked private in Xcode 9. The following AVFoundation API are temporarily unavailable:
AVCaptureDevice.Format.supportedColorSpaces
AVCaptureDevice.supportedFlashModes
AVCapturePhotoOutput.availablePhotoPixelFormatTypes
AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes
AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes
As a workaround you can use the SwiftPrivate versions of these API by prepending each API with double underscore (
__
). For example, changeAVCaptureDevice.Format.supportedColorSpaces
toAVCaptureDevice.Format.__supportedColorSpaces
.
我可以确认使用 __availablePreviewPhotoPixelFormatTypes
修复了构建错误。
例如
let settings = AVCapturePhotoSettings()
let previewPixelType = settings.__availablePreviewPhotoPixelFormatTypes.first!
来源:https://forums.developer.apple.com/thread/86810#259270
2017 年 9 月 14 日更新:
问题在 Xcode 9.0 GM (9A235) 中再次出现。
已提交新错误报告以供引用:rdar://34420979
上一个:
更新:已在 Xcode Beta 6 中修复。
针对 Xcode 版本 9.0 beta 5 (9M202q) 提交了错误报告 rdar://33935456
。
关于ios - 尝试 Apple 的 Sample AVCAM 发现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45668293/