flutter macOS 构建出错

今天尝试用flutter构建一个 macOS 应用,结果一直报错:

/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.12, but the range of supported deployment target versions is 10.13 to 14.4.99. (in target 'AppAuth-AppAuthCore_Privacy' from project 'Pods')

找了很久都没有找到原因,直到我搜索 MACOSX_DEPLOYMENT_TARGET,发现 macos/Pods/Pods.xcodeproj/project.pbxproj 里有许多 这个变量,但是版本确实是很低,我尝试手动改写一下,把版本统一到 10.15,结果发现还真的编译成功了,只是 pub get 以后再次编译的时候, 又回报错,原因是这个变量又被覆盖了。

最后找到的解决办法,编辑 macos/Podfilepost_install 部分,从

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

改成

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_macos_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.15'
    end
  end
end

再次生成,就不会报错了,这里的原理,其实就是强制改写每一个依赖的最低构建版本。

坑呀!又踩了一个。


ref: https://stackoverflow.com/questions/72891223/what-should-i-do-to-change-the-macosx-deployment-target-when-build-flutter-macos


更多文章
  • Golang 实践经验
  • 高性能MySQL笔记第一章
  • 面试的一些技巧
  • HTTP/2 简介
  • 独立运营博客一年的一些数据分享
  • To B(usiness) 和 To C(ustomer)
  • Cookie 中的secure和httponly属性
  • 常见的软件架构套路
  • Google Ads使用体验
  • Go的custom import path
  • 如何挖掘二级子域名?
  • Go Module 简明教程
  • 写了一个Telegram Bot:自动化分享高质量内容
  • 为什么我选择放弃运营微信公众号?
  • ArchLinux 怎么降级 package ?