Flutter - iOS模拟器部署目标'IPHONEOS_DEPLOYMENT_TARGET'设置为7.0 && 找不到构建输入文件GoogleService-Info.plist。

38

我无法在iOS模拟器上构建Flutter应用程序。 我一遍又一遍地收到这个错误。 我的flutter-doctor检查结果是干净的。

 Launching lib/main.dart on iPhone SE (2nd generation) in debug mode...
    Xcode build done.                                           26,7s
    Failed to build iOS app
    Error output from Xcode build:
    ↳
        ** BUILD FAILED **
    Xcode's output:
    ↳
        error: Build input file cannot be found: '/Users/User/Downloads/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')
        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 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'AppAuth' from project 'Pods')
        warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'GTMAppAuth' from project 'Pods')
        warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'gRPC-Core' from project 'Pods')
        warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'BoringSSL-GRPC' from project 'Pods')
        warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 5.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'leveldb-library' from project 'Pods')
        warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'gRPC-C++-gRPCCertificates-Cpp' from project 'Pods')
        warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 4.3, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'nanopb' from project 'Pods')
        warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'GTMSessionFetcher' from project 'Pods')
        warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'gRPC-C++' from project 'Pods')
        warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'abseil' from project 'Pods')
    Could not build the application for the simulator.
    Error launching application on iPhone SE (2nd generation).
    Exited (sigterm)

Flutter doctor

5个回答

49
为了消除这个警告:
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'AppAuth' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'GTMAppAuth' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'gRPC-Core' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'BoringSSL-GRPC' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 5.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'leveldb-library' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'gRPC-C++-gRPCCertificates-Cpp' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 4.3, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'nanopb' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'GTMSessionFetcher' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'gRPC-C++' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.4.99. (in target 'abseil' from project 'Pods')

请确保你的Podfile文件中包含以下内容:

config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'

post_install do |installer|
  installer.pods_project.targets.each do |target|
  flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
    end
  end
end
为了让应用程序能够成功构建并消除以下问题:
error: Build input file cannot be found: '/Users/User/Downloads/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')

通过Xcode,删除并重新添加GoogleService-Info.plist文件。


5
当我进行这个操作时,现在出现了以下错误信息:“从/Users/mridley/_development/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.3+2/ios/Classes/FLTPackageInfoPlugin.m:5包含的文件:/Users/mridley/_development/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.3+2/ios/Classes/FLTPackageInfoPlugin.h:5:9: 致命错误:找不到 'Flutter/Flutter.h' 文件”。你有什么想法吗? - RiddlerDev
2
@RiddlerDev 运行 'flutter pub cache repair & flutter clean & cd ios & pod deintegrate & flutter pub get',然后再次运行应用程序。 - maxpill
1
对于Flutter应用程序,需要在installer.pods_project.targets.each do |target|行之后添加flutter_additional_ios_build_settings(target),否则会出现“找不到'Flutter/Flutter.h'文件”的错误。建议联系@RiddlerDev获取更多帮助。 - goldensoju

7

对maxpills答案的小改进

post_install do |installer|

  puts 'Determining pod project minimal deployment target'

  pods_project = installer.pods_project
  deployment_target_key = 'IPHONEOS_DEPLOYMENT_TARGET'
  deployment_targets = pods_project.build_configurations.map{ |config| config.build_settings[deployment_target_key] }
  minimal_deployment_target = deployment_targets.min_by{ |version| Gem::Version.new(version) }

  puts 'Minimal deployment target is ' + minimal_deployment_target
  puts 'Setting each pod deployment target to ' + minimal_deployment_target

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings[deployment_target_key] = minimal_deployment_target
    end
  end
end

这是使用在Podfile开头定义的目标版本

platform :ios, '9.0'

1
你的代码里有一行写着'DEBUG=1'],这是复制粘贴错误吗? :) - p0wl
肯定是 @p0wl - maxpill
那么真正的问题是:是否缺少半行代码,还是我应该只删除'DEBUG=1'] - p0wl
1
你能否修复这个答案中的语法错误? - Stevey

2

对我来说,在XCode中突出显示的字段中设置为8.0,将其设置为10可以解决我的问题。

enter image description here


1

Project Document in attributes inspector highlighted

  1. 打开 Xcode
  2. 更改项目文档 -> 项目格式 -> 兼容 Xcode 8.0
  3. flutter clean, flutter pub get 和 flutter build iOS

0
我稍微修改了@Hons的答案,以解决我在使用Xcode 12.5时同时使用OneSignaluni_links 0.5.1包时遇到的问题。
编辑./ios/Podspec文件,取消注释文件的第二行(并更新最低目标版本)。
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

然后将 OneSignal 的目标代码和 post_install 脚本替换为:

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignalXCFramework', '3.2.1'
end

post_install do |installer|
  puts 'Determining pod project minimal deployment target'
  pods_project = installer.pods_project
  deployment_target_key = 'IPHONEOS_DEPLOYMENT_TARGET'
  deployment_targets = pods_project.build_configurations.map{ |config| config.build_settings[deployment_target_key] }
  minimal_deployment_target = deployment_targets.min_by{ |version| Gem::Version.new(version) }
  puts 'Minimal deployment target is ' + minimal_deployment_target
  puts 'Setting each pod deployment target to ' + minimal_deployment_target
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings[deployment_target_key] = minimal_deployment_target
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接