3

flutter macOS 构建出错

 1 month ago
source link: https://jiajunhuang.com/articles/2024_03_20-flutter_macos.md.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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


Go 泛型简明教程 KVM 显卡穿透给 Windows 使用 HTTP Router 处理 Telegram Bot 按钮回调 使用反射(reflect)对结构体赋值 GIN 是如何绑定参数的 你好 2022(2021 年终总结) 用Go导入大型CSV到PostgreSQL 使用 OpenWRT 搭建软路由 使用软KVM切换器 barrier 共享键鼠 SQL 防注入及原理 使用 gomock 测试 Go 代码 gevent不是黑魔法(二): gevent 实现 gevent不是黑魔法(一): greenlet 实现 用 entgo 替代 gorm 应用内使用crontab不是那么方便



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK