Apple Mach-O Linker(ld)错误组与Swift 3& Xcode 9 GM [英] Apple Mach-O Linker (ld) Error Group with Swift 3 & Xcode 9 GM
问题描述
在GM Xcode(和iOS 11)之前运行良好。现在我收到这些错误:
This was running fine till GM Xcode (and iOS 11). Now I get these errors:
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日更新:
Apple的官方回复:
Update 15 Sept 2017:
Official response from Apple:
我们的道歉。对于使用Swift 3.2或Swift 4.0的应用程序,几个
AVFoundation捕获API(外部协议上的公共扩展)
在Xcode 9中无意中被标记为私有。以下
AVFoundation API暂时不可用:
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
作为解决方法,您可以使用SwiftPrivate这些API
的版本通过在每个API前加上双下划线( __
)。例如,
将 AVCaptureDevice.Format.supportedColorSpaces
更改为
AVCaptureDevice.Format .__ supportedColorSpaces
。
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
修复了构建错误。
I can confirm using __availablePreviewPhotoPixelFormatTypes
fixes the build errors.
例如。
let settings = AVCapturePhotoSettings()
let previewPixelType = settings.__availablePreviewPhotoPixelFormatTypes.first!
资料来源: https://forums.developer.apple.com/thread/86810#259270
这篇关于Apple Mach-O Linker(ld)错误组与Swift 3& Xcode 9 GM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!