flutter iOS 打包问题

今天写着写着出现了问题。记录一下,用android Studio 打包flutter项目 报错如下:

Launching lib/main.dart on iPhone 12 Pro in debug mode...
Running pod install...
Running Xcode build...
Xcode build done.                                            6.2s
Failed to build iOS app
Error output from Xcode build:** BUILD FAILED **


Xcode's output:
↳

    Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
    /Users/mdkmdk/moepad-flutter/moegirl/ios/Pods/Pods.xcodeproj: 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.5.99. (in target 'flutter_webview_plugin' from project 'Pods')
    /Users/mdkmdk/moepad-flutter/moegirl/ios/Pods/Pods.xcodeproj: 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.5.99. (in target 'Flutter' from project 'Pods')

Could not build the application for the simulator.
Error launching application on iPhone 12 Pro.

看这个日志得一步一步解决
首先是这个

/Users/mdkmdk/moepad-flutter/moegirl/ios/Pods/Pods.xcodeproj: 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.5.99. (in target 'flutter_webview_plugin' from project 'Pods')
/Users/mdkmdk/moepad-flutter/moegirl/ios/Pods/Pods.xcodeproj: 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.5.99. (in target 'Flutter' from project 'Pods')

修改podfile文件,把最下面的

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

改成

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['IPHONEOS_DEPLOYMENT_TARGET'] =9.0’
      end
    end
end

最终问题解决,竟然是pubspec.yaml的问题。要仔细检查这个配置文件。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐