Swift Apple Mach-O 链接器错误

Swift Apple Mach-O linker error

我将我的项目从 swift 3 转换为 swift 4 并使用最新版本的 xcode 9。在构建时,我收到以下错误:

Undefined symbols for architecture arm64: "__T0So22AVCapturePhotoSettingsC12AVFoundation01_abC16SwiftNativeTypesACWP", referenced from: __T06SpotMi8CameraVCC12capturePhotoyypF in CameraVC.o "__T012AVFoundation39_AVCapturePhotoSettingsSwiftNativeTypesPAAE016availablePreviewc11PixelFormatG0SaySo8NSNumberCGfg", referenced from: __T06SpotMi8CameraVCC12capturePhotoyypF in CameraVC.o ld: symbol(s) not found for architecture arm64 我没有线索了。任何帮助将不胜感激。

干杯!

XCode9 中存在错误。 Apple 无意中将 AVFoundation 中的某些函数设为私有。

解决方法:

将源代码中的 availablePreviewPhotoPixelFormatTypes 更改为 __availablePreviewPhotoPixelFormatTypes

同样适用于以下情况:

supportedColorSpaces -> __supportedColorSpaces

supportedFlashModes -> __supportedFlashModes

availableRawPhotoPixelFormatTypes -> __availableRawPhotoPixelFormatTypes

availablePhotoPixelFormatTypes -> __availablePhotoPixelFormatTypes

然后它可能会编译! 祝你好运!