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


更多文章
  • 编写可维护的单元测试代码
  • OAuth 2 详解(六):Authorization Code Flow with PKCE
  • OAuth 2 详解(五):Device Authorization Flow
  • OAuth 2 详解(四):Client Credentials Flow
  • OAuth 2 详解(三):Resource Owner Password Credentials Grant
  • OAuth 2 详解(二):Implict Grant Flow
  • OAuth 2 详解(一):简介及 Authorization Code 模式
  • ElasticSearch 学习笔记
  • 三种git流程以及发版模型
  • 错误处理实践
  • 权限模型(RBAC/ABAC)
  • OIDC(OpenID Connect) 简介
  • 任务队列简介
  • 使用Drone CI构建CI/CD系统
  • PostgreSQL 操作笔记