IPHONEOS_DEPLOYMENT_TARGET 设置为 8.0 Xcode 12 (Flutter)

Posted

技术标签:

【中文标题】IPHONEOS_DEPLOYMENT_TARGET 设置为 8.0 Xcode 12 (Flutter)【英文标题】:IPHONEOS_DEPLOYMENT_TARGET is set to 8.0 Xcode 12 (Flutter) 【发布时间】:2021-03-08 12:52:06 【问题描述】:

我在 android Studio 中运行我的 Flutter 项目,Pod 安装顺利,但每次 Xcode 构建最终都会失败,例如完成整个构建的 20/30 步。 奇怪的事实是 Android Studio 说:

Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
warning: The ios Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'GoogleDataTransport' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'path_provider' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'nanopb' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'BoringSSL-GRPC' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'AppAuth' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'GoogleUtilities' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'GTMAppAuth' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'gRPC-C++' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'google_sign_in' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'FirebaseCoreDiagnostics' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'FirebaseCore' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'FirebaseFirestore' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'FirebaseAuth' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'firebase_core' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'firebase_auth' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'cloud_firestore' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'gRPC-Core' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'Firebase' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'gRPC-C++-gRPCCertificates-Cpp' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'GoogleSignIn' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'leveldb-library' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'Flutter' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.2.99. (in target 'abseil' from project 'Pods')

但是当我用 Xcode 打开工作区时,我看到我在 Runner 中的目标有 iOS deployment target 14.0 所以我不明白,它应该设置为 14 但实际上是 8。 Flutter 生成的PodfilePodfile.lockPodsflutter run 我更喜欢让Flutter 处理Pod 的生成和安装,而不使用pod initpod install 或编辑Podfile

【问题讨论】:

你能分享你的 ios/Podfile 吗? 【参考方案1】:

除了 Akif 所说的之外,以下是可能会出现此错误的原因的运行列表:

    ios/Flutter/AppFrameworkInfo.plist 中将MinimumOSversion 设置为9.0 在Xcode中,确保Runner -> Project -> Runner的iOS部署目标设置为9.0 在 Xcode 中,确保 Runner -> Targets -> Runner 中的 Deployment Info 设置为 iOS 9.0 仔细检查您的 GoogleService-Info.plist 是否存在并且是通过 Xcode 添加的(例如,不是通过 Finder 复制/粘贴到目录中) 在ios/Podfile 中取消注释#platform :iOS, '9.0'

然后,在您的终端中运行以下命令以使用新状态进行构建:

flutter clean \
        && rm ios/Podfile.lock pubspec.lock \
        && rm -rf ios/Pods ios/Runner.xcworkspace \
        && flutter build ios

【讨论】:

这里不是“Deployment info”而是“Deployment target”,而且都设置为14,是一样的吗? 我做了所有这些事情,但是当运行结束时,我将“MinimumiOSVersion”恢复到 8.0...再次出现同样的错误 @FinleyAdams 确保设置正确的AppFrameworkInfo.plist,即ios/Flutter。我知道还有另一个 AppFrameworkInfo 将在构建时覆盖,这可能是您正在使用的。 “flutter build iOS”应该是小写的“flutter build ios” 不幸的是我得到了这个:The Xcode project defines schemes: dev, prod, staging You must specify a --flavor option to select one of the available schemes.。我花了一整天的时间来弄清楚如何解决这个问题.. 从 2.0.3 迁移到 2.0.5【参考方案2】:

替换这个pod文件的代码:

post_install do |installer|
 installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
   config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
  end
 end
end

【讨论】:

【参考方案3】:

您需要在ios/Flutter/AppFrameworkInfo.plist 中将MinimumOSVersion 设置为9.0。它看起来像这样:

  <key>MinimumOSVersion</key>
  <string>9.0</string>

【讨论】:

我没有这个文件夹。我的路径是“ios/Flutter/”,在 Flutter 内部我有“App.framework、flutter_export_enviroment.sh、Flutter.framework、Flutter.podspec、Generated.xconfig”。但在 Flutter.framework 内部有一个“Info.plist”。是的,这里有声音“MinimumiOSVersion”,我将它设置为 14,对吗? 不,设置为 9。 好吧,我相信你,但为什么呢?为较新的版本设置它不是更好吗? 没有。您正在定义最低操作系统版本。对于 iOS,它至少应该是 9.0。 10、11、12、13、14 等较新版本可以使用您的应用。但是如果你设置为 14,那么只有 iOS14 的 iPhone 会使用你的应用。 哦,你是对的,谢谢!好的,我做到了,但是当运行结束时,该行已更改回 8.0,并且我遇到了同样的错误。【参考方案4】:

如果在尝试了上述所有解决方案后,您的代码仍然无法正常工作,尤其是在更新/升级之后...

只需检查您的 dart 版本并检查 null 安全包...

在与错误作斗争数天后,我刚刚通过将我的代码正确迁移到零安全性解决了我的问题。

【讨论】:

查看飞镖版本是什么意思?以及如何解决这个问题?你能详细说明一下吗?【参考方案5】:

enter image description here

    打开xcode 更改项目文档 - 项目格式 - Xcode 8.0-兼容 flutter clean,flutter pub 获取一个 flutter build ios

【讨论】:

【参考方案6】:

错误是不言自明的,应用程序缺少部署目标。

这将被添加到 Xcode 中的两个地方,请查看以下屏幕截图,其中提到了 iOS 部署目标

1.跑步者

2.Pod

【讨论】:

以上是关于IPHONEOS_DEPLOYMENT_TARGET 设置为 8.0 Xcode 12 (Flutter)的主要内容,如果未能解决你的问题,请参考以下文章