问题描述
自 xcode 12.5 更新以来,我无法使用自己的框架构建应用程序。
Failed to build module 'mySwiftxcFramework' from its module interface; the compiler that produced it,'Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)',may have used features that aren't supported by this compiler,'Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)'
我的框架正在使用 https://github.com/ashleymills/Reachability.swift ,并且我在生成的文件上有另一个错误:x86_64-apple-ios-simulator.swiftinterface 在这一行:
extension MySwiftFramework.Reachability.NetworkStatus : Swift.Hashable {}
Conformance of 'Reachability.NetworkStatus' to 'Equatable' is unavailable
经过一些修改后,我终于用 Swift 5.4 构建了我的库 (xcframework),但是当我尝试导入或嵌入到我的应用程序中时,我在符合 equatable 方面遇到了同样的错误,但还有这个新错误:
>Failed to build module 'mySwiftxcFramework' from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced
解决方法
我通过向 NetworkStatus 添加 Equatable 一致性来编辑 Reachability.swift。发布后,使用 xcode 版本 12.5.1 再次重建了框架。我能够在应用程序中成功导入框架并且没有错误。