Xcode 12:为 iOS 10.0 编译,但模块 'RxSwift' 的最低部署目标为 iOS 12.0

Xcode 12: Compiling for iOS 10.0, but module 'RxSwift' has a minimum deployment target of iOS 12.0

我刚更新Xcode到最新版本,项目不再编译。我删除了所有内容并尝试重建 pods 但最终遇到了同样的问题:

[x] /Users/alouanemed/Projects/App-iOS/Pods/_Prebuild/Moya/Sources/RxMoya/MoyaProvider+Rx.swift:2:8: compiling for iOS 10.0, but module 'RxSwift' has a minimum deployment target of iOS 12.0: /Users/alouanemed/Projects/App-iOS/Pods/build/Release-iphoneos/RxSwift/RxSwift.framework/Modules/RxSwift.swiftmodule/arm64-apple-ios.swiftmodule

import RxSwift ^

您要导入的 RxSwift 版本已将其最低部署目标设置为 iOS 12.0,而您的项目本身仍在 iOS 10.0。

这应该与 Xcode 或 Xcode 更新无关。

如果你可以 post 你的 Podfile 我们可以验证这一点。

使用 cocoapods 和 Xcode 12,您目前需要在所谓的“post-install hook”中设置 Pods' 部署目标。

尝试将此添加到 Podfile 的末尾:


deployment_target = '12.0'

post_install do |installer|
    installer.generated_projects.each do |project|
        project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
            end
        end
        project.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
        end
    end
end

只写给可能和我遇到同样情况的人。这个错误的原因是我正在使用 beta 频道。切换到stable频道后,我运行

cd ios/
pod deintegrate
pod cache clean --all
cd ..
flutter clean

而且,我删除了 PodfilePodfile.lock。然后,我再次构建了该项目并且成功了!