构建flutter macos应用程序时,我应该如何更改MACOSX_DEPLOYMENT_TARGET

hpxqektj  于 2023-01-09  发布在  Flutter
关注(0)|答案(4)|浏览(311)

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

~/fvm/versions/3.0.4/bin/flutter build macos --release

显示如下错误:

➜  macos git:(main) ✗ ~/fvm/versions/3.0.4/bin/flutter build macos --release --no-tree-shake-icons
Changing current working directory to: /Users/xiaoqiangjiang/source/reddwarf/frontend/tik

💪 Building with sound null safety 💪

Running pod install...                                             668ms
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00006000-001248980AE2801E }
{ platform:macOS, arch:x86_64, id:00006000-001248980AE2801E }
/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')
Building macOS application...

我已经将Pod和Runner部署目标更改为10.11。要更改MACOSX_DEPLOYMENT_TARGET版本,我应该做些什么?这是macos podfile:

platform :osx, '10.11'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_macos_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
end

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

这是Pod macOS部署配置:

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

eqzww0vc

eqzww0vc1#

进入我的macos/Podfile,并取代了post_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

来源:https://levelup.gitconnected.com/how-to-fix-your-flutter-macos-target-mismatch-bc55424b7c77
希望能有所帮助!

mrwjdhj3

mrwjdhj32#

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

zpjtge22

zpjtge223#

在xcode中选择目标,然后选择构建设置。确保它显示组合选项。检查有效的架构。删除您不使用的架构。
也请采取备份的yhe项目和运行
第一个月

uurity8g

uurity8g4#

经过几个小时的寻找解决方案,找到了。
需要在2个地方进行更改,但更改为同一个文件。该文件为macos/Runner.xcworkspace
在Finder中显示它,并使用XCode打开。
文件中的第一个变更:Runner〉General〉Minimum Deployment.设置为列表中的最小值或所需值(在我的例子中是10.13)
文件中的第二个变更:Flutter Assemble〉Build Settings〉macOS部署目标。设置为与之前相同(在我的情况下为10.13)
切换到Flutter组装,使用子菜单下的亚军。这是我的困惑。2的变化需要在同一个文件,只有选择亚军或Flutter组装与上级菜单下亚军。看到以下视频的细节了
https://youtu.be/iqGHugqyDiM
希望这能有所帮助。
随附2张照片。x1c 0d1x

相关问题