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


更多文章
  • Vim YouCompleteMe使用LSP(以dart为例)
  • flutter webview加载时显示进度
  • SQLAlchemy快速更新或插入对象
  • 修复Linux下curl等无法使用letsencrypt证书
  • 欣赏一下K&R两位大神的代码
  • MySQL的ON DUPLICATE KEY UPDATE语句
  • 使用microk8s快速搭建k8s
  • Python中优雅的处理文件路径
  • Go语言MySQL时区问题
  • 我的技术栈选型
  • 为什么我要用Linux作为桌面?
  • disqus获取评论时忽略query string
  • MySQL性能优化指南
  • 网络编程所需要熟悉的那些函数
  • DNSCrypt简明教程