构建 flutter macos 应用程序时我应该做什么来更改 MACOSX_DEPLOYMENT_TARGET

Dol*_*hin 15 macos xcode flutter

我正在使用以下命令v3.0.4在 macOS( ) 中构建 flutter( ) macos 应用程序:v12.4 M1 chip

\n
~/fvm/versions/3.0.4/bin/flutter build macos --release\n
Run Code Online (Sandbox Code Playgroud)\n

显示这样的错误:

\n
    \xe2\x9e\x9c  macos git:(main) \xe2\x9c\x97 ~/fvm/versions/3.0.4/bin/flutter build macos --release --no-tree-shake-icons\nChanging current working directory to: /Users/xiaoqiangjiang/source/reddwarf/frontend/tik\n\n Building with sound null safety \n\nRunning pod install...                                             668ms\n--- xcodebuild: WARNING: Using the first of multiple matching destinations:\n{ platform:macOS, arch:arm64, id:00006000-001248980AE2801E }\n{ platform:macOS, arch:x86_64, id:00006000-001248980AE2801E }\n/Users/xiaoqiangjiang/source/reddwarf/frontend/tik/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target \'MACOSX_DEPLOYMENT_TARGET\' is set to 10.6, but the range of supported deployment target versions is 10.9 to 12.3.99. (in target \'FMDB\' from project \'Pods\')\nBuilding macOS application...\n
Run Code Online (Sandbox Code Playgroud)\n

我已经将 Pods 和 Runner 部署目标更改为 10.11。我应该怎么做才能更改MACOSX_DEPLOYMENT_TARGET 版本?这是 macOS 的 podfile:

\n
platform :osx, \'10.11\'\n\n# CocoaPods analytics sends network stats synchronously affecting flutter build latency.\nENV[\'COCOAPODS_DISABLE_STATS\'] = \'true\'\n\nproject \'Runner\', {\n  \'Debug\' => :debug,\n  \'Profile\' => :release,\n  \'Release\' => :release,\n}\n\ndef flutter_root\n  generated_xcode_build_settings_path = File.expand_path(File.join(\'..\', \'Flutter\', \'ephemeral\', \'Flutter-Generated.xcconfig\'), __FILE__)\n  unless File.exist?(generated_xcode_build_settings_path)\n    raise "#{generated_xcode_build_settings_path} must exist. If you\'re running pod install manually, make sure \\"flutter pub get\\" is executed first"\n  end\n\n  File.foreach(generated_xcode_build_settings_path) do |line|\n    matches = line.match(/FLUTTER_ROOT\\=(.*)/)\n    return matches[1].strip if matches\n  end\n  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \\"flutter pub get\\""\nend\n\nrequire File.expand_path(File.join(\'packages\', \'flutter_tools\', \'bin\', \'podhelper\'), flutter_root)\n\nflutter_macos_podfile_setup\n\ntarget \'Runner\' do\n  use_frameworks!\n  use_modular_headers!\n\n  flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))\nend\n\npost_install do |installer|\n  installer.pods_project.targets.each do |target|\n    flutter_additional_macos_build_settings(target)\n  end\nend\n
Run Code Online (Sandbox Code Playgroud)\n

这是 Pods macOS 部署配置:

\n

在此输入图像描述

\n

我已经尝试清理构建并重建 macos 应用程序,但仍然无法按预期工作。

\n

小智 37

进入我的 macos/Podfile 并替换看起来像这样的 post_install 方法 \xe2\x80\xa6

\n
post_install do |installer|\n  installer.pods_project.targets.each do |target|\n    flutter_additional_macos_build_settings(target)\n  end\nend\n
Run Code Online (Sandbox Code Playgroud)\n

看起来像这样。

\n
post_install do |installer|\n  installer.pods_project.targets.each do |target|\n    flutter_additional_macos_build_settings(target)\n    target.build_configurations.each do |config|\n      config.build_settings[\'MACOSX_DEPLOYMENT_TARGET\'] = \'10.15\'\n    end\n  end\nend\n
Run Code Online (Sandbox Code Playgroud)\n

来源:\n https://levelup.gitconnected.com/how-to-fix-your-flutter-macos-target-mismatch-bc55424b7c77

\n

希望能帮助到你!

\n


Ali*_*san 6

在 Xcode 中打开macos文件夹,然后在项目导航器中选择Pods 。选择框架目标并选择常规选项卡。

在 Pod 中更改此部署目标并保存将解决该问题的更改


CNK*_*CNK 5

经过几个小时寻找解决方案,找到了。

需要在两个地方进行更改,但更改为同一个文件。该文件是 macos/Runner.xcworkspace

在 Finder 中显示它,并使用 XCode 打开。

文件中的第一个更改:运行程序 > 常规 > 最小部署。设置为列表中的最小值或所需值(在我的例子中为 10.13)

文件中的第二个更改:Flutter Assemble > Build Settings > macOS Deployment Target。设置为与之前相同(在我的例子中为 10.13)

要切换到 Flutter Assemble,请使用 Runner 下面的子菜单。这是我的困惑。这 2 个更改需要在同一个文件中进行,并且只需在 Runner 下的上方菜单中选择 Runner 或 Flutter Assemble。也请参阅以下视频,其中包含详细信息

https://youtu.be/iqGHugqyDiM

希望这能有所帮助。

附2张照片。 运行器 > 常规 > 最小部署

Flutter Assemble > 构建设置 > macOS 部署目标