尝试 Apple 的 Sample AVCAM 发现错误
Try Sample AVCAM from apple found error
当我使用 Xcode 版本 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)
问题是什么?以及如何解决这个问题?
尝试将 AVFoundation 添加到链接框架(目标 -> 构建阶段 -> Link 带库的二进制文件)
这似乎是一个 Xcode 错误。示例代码在 Xcode 9.0 beta (9M136h) 中构建良好。向 Apple 报告为 rdar://33903950.
更新:雷达现已关闭。问题已在 Xcode 9.0 Beta 6 (9M214v) 中修复。
Xcode 9.0 beta 5 (9M202q) AVCam Swift 修订版 2017-06-06 肯定有问题。幸运的是,问题被隔离到 CameraViewController.swift
:
中的这三行
if !photoSettings.availablePreviewPhotoPixelFormatTypes.isEmpty {
photoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String: photoSettings.availablePreviewPhotoPixelFormatTypes.first!]
}
注释掉上面的代码,AVCam 将编译并 运行 在设备 运行 上运行最新的 iOS 11 beta。
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,
change AVCaptureDevice.Format.supportedColorSpaces
to
AVCaptureDevice.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
。
当我使用 Xcode 版本 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)
问题是什么?以及如何解决这个问题?
尝试将 AVFoundation 添加到链接框架(目标 -> 构建阶段 -> Link 带库的二进制文件)
这似乎是一个 Xcode 错误。示例代码在 Xcode 9.0 beta (9M136h) 中构建良好。向 Apple 报告为 rdar://33903950.
更新:雷达现已关闭。问题已在 Xcode 9.0 Beta 6 (9M214v) 中修复。
Xcode 9.0 beta 5 (9M202q) AVCam Swift 修订版 2017-06-06 肯定有问题。幸运的是,问题被隔离到 CameraViewController.swift
:
if !photoSettings.availablePreviewPhotoPixelFormatTypes.isEmpty {
photoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String: photoSettings.availablePreviewPhotoPixelFormatTypes.first!]
}
注释掉上面的代码,AVCam 将编译并 运行 在设备 运行 上运行最新的 iOS 11 beta。
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
。