【问题标题】:what should I do to change the MACOSX_DEPLOYMENT_TARGET when build flutter macos app构建flutter macos应用程序时我应该怎么做才能更改MACOSX_DEPLOYMENT_TARGET
【发布时间】:2022-08-03 00:00:26
【问题描述】:

我正在使用以下命令在 macOS(v12.4 M1 chip) 中构建颤振(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...

我已经将 Pods 和 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

这是 Pods macOS 部署配置:

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

    标签: xcode flutter macos


    【解决方案1】:

    在 xcode 中选择目标,然后选择构建设置。确保它显示组合选项。检查有效的架构。删除您不使用的架构。

    另外请备份项目并运行

    pod install --repo-update

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 我签入 xcode 并已将版本更改为 10.11@Ali Hassan
      【解决方案3】:

      进入我的 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

      希望能帮助到你!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-05-20
        • 1970-01-01
        • 2020-05-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多