ios - Apple Mach-O Linker (ld) Error Group with Swift 3 & Xcode 9 GM

标签 ios swift xcode swift3 avfoundation

这在 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, 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

关于ios - Apple Mach-O Linker (ld) Error Group with Swift 3 & Xcode 9 GM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46202060/

相关文章:

ios - 不续订订阅 - 恢复

ios - 自定义 XIB 未加载问题

ios - 设备时间格式设置为24小时时获取零日期

ios - 按下按钮时如何获得标签以显示随机文本? [ swift ]

ios - 在 Xcode 7 中使用 ios 8.4 SDK 构建和调试

ios - '无法在包 : 'NSBundle | Error while switching to Xcode 4 and creating an iPad version of an app 中加载 NIB

ios - 使用 MKAnnotation 继续下一个 View Controller

ios - 为什么 Crashlytics 中缺少 CLSLog 消息?

ios - Branch.io - 链接打开应用程序但未获取其中的数据

iphone - NSXMLParser 不会忽略 CDATA