这在 GM Xcode(和 iOS 11)之前运行良好。现在我得到这些错误:
Apple Mach-O Linker (ld) Error Group
"__T0So20AVCapturePhotoOutputC12AVFoundation01_abC16SwiftNativeTypesACWP", referenced from:
xxxxxxxxxx
"__T012AVFoundation37_AVCapturePhotoOutputSwiftNativeTypesPAAE012availableRawc11PixelFormatG0SaySo8NSNumberCGfg", referenced from:
xxxxxxxxx
" "__T0So22AVCapturePhotoSettingsC12AVFoundation01_abC16SwiftNativeTypesACWP", referenced from:
xxxxxxxxxx
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
它指向的一些行是:
photoSettings = AVCapturePhotoSettings(rawPixelFormatType: OSType(self.photoOutput.availableRawPhotoPixelFormatTypes.first!))
photoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String: photoSettings.availablePreviewPhotoPixelFormatTypes.first!.uint32Value,
kCVPixelBufferWidthKey as String: 3024, kCVPixelBufferHeightKey as String: 3024]
还有:
let rawFormat = self.photoOutput.availableRawPhotoPixelFormatTypes.first!.uint32Value
photoSettings = AVCapturePhotoSettings(rawPixelFormatType: OSType(rawFormat),
processedFormat: [AVVideoCodecKey : AVVideoCodecJPEG,
AVVideoCompressionPropertiesKey : [AVVideoQualityKey : 1.0]] as [String : Any])
photoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String: photoSettings.availablePreviewPhotoPixelFormatTypes.first!.uint32Value,
kCVPixelBufferWidthKey as String: 3024,
kCVPixelBufferHeightKey as String: 3024]
最佳答案
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!
关于ios - Apple Mach-O Linker (ld) Error Group with Swift 3 & Xcode 9 GM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46202060/