且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-12-03 15:21:10

2017 年 9 月 15 日更新:

苹果官方回应:

我们深表歉意.对于使用 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

作为一种解决方法,您可以使用这些 API 的 SwiftPrivate 版本通过在每个 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