一尘不染

带有Swift 3和Xcode 9 GM的Apple Mach-O Linker(ld)错误组

swift

在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]

阅读 223

收藏
2020-07-07

共1个答案

一尘不染

2017年9月15日更新:

苹果官方回应:

我们的歉意。对于使用Swift 3.2或Swift 4.0的应用程序,一些AVFoundation捕获API(外部协议的公共扩展)在Xcode
9中被无意中标记为私有。以下AVFoundation API暂时不可用:

  • AVCaptureDevice.Format.supportedColorSpaces

  • AVCaptureDevice.supportedFlashModes

  • AVCapturePhotoOutput.availablePhotoPixelFormatTypes

  • AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes

  • AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes

作为解决方法,您可以通过在每个API前面加上双下划线(__)来使用这些API的SwiftPrivate版本。例如,更改AVCaptureDevice.Format.supportedColorSpaces
AVCaptureDevice.Format.__supportedColorSpaces

我可以确认使用__availablePreviewPhotoPixelFormatTypes修复程序生成错误。

例如

let settings = AVCapturePhotoSettings()
let previewPixelType = settings.__availablePreviewPhotoPixelFormatTypes.first!

资料来源:https :
//forums.developer.apple.com/thread/86810#259270

2020-07-07