当构建Flutter Macos应用时

发布于 2025-02-14 02:03:32 字数 378 浏览 0 评论 0 原文

我正在MacOS( v3.0.4 )MacOS App( v3.0.4 )使用此命令:

~/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


              

I am building flutter(v3.0.4) macos app in macOS(v12.4 M1 chip) using this command:

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

shows error like this:

    ➜  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...

I have already change the Pods and Runner deployment target to 10.11. what should I do to change the MACOSX_DEPLOYMENT_TARGET version? this is the 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

this is the Pods macOS deployment config:

enter image description here

I have already tried to clean the build and rebuild the macos app but still could not work as expect.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

万水千山粽是情ミ 2025-02-21 02:03:32

进入了我的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-fix-your-flutter-macos-target-mismatch-bc55424b7c77

希望它对您有所帮助!

Went into my macos/Podfile and replaced the post_install method that looked like so…

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

to look like so instead.

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

source:
https://levelup.gitconnected.com/how-to-fix-your-flutter-macos-target-mismatch-bc55424b7c77

Hope it helps!

肤浅与狂妄 2025-02-21 02:03:32

几个小时后寻找解决方案,找到了它。

需要在2个位置上更改,但要变成同一文件。
该文件是macOS/runner.xcworkspace

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

文件中的第一个更改:
跑步者>一般>最小部署。
将列表中的最小值设置为或所需的(在我的情况下10.13)

文件中的第二个更改:
Flutter组装>构建设置> MACOS部署目标。
设置为与以前的相同(在我的情况下为10.13)

以切换到扑朔迷离的组装,请使用下方的子菜单。这是我的困惑。这两个更改需要在同一文件中进行,并且只有选择Runner或flutter与Runner下的上菜单组装。
请参阅以下视频,其中包括详细信息

https://youtu.be/iqghugqydim

希望这可以帮助您。

附有2张照片。
最低部署”>

MacOS部署目标“>

After hours looking for a solution, found it.

Need to change at 2 places but into the very same file.
The file is macos/Runner.xcworkspace

Reveal it in Finder, and open with XCode.

1st change in the file:
Runner > General > Minimum Deployment.
Set to minimum in the list or desired (in my case 10.13)

2nd change in the file:
Flutter Assemble > Build Settings > macOS Deployment Target.
Set to the same as before (in my case 10.13)

To switch to the Flutter Assemble, use the submenu below Runner. This was my confusion. The 2 changes need to be made in the very same file and only select Runner or Flutter Assemble with the upper menu under Runner.
See the following video with details too

https://youtu.be/iqGHugqyDiM

Hope this can help.

Attached 2 photos.
Runner > General > Minimum Deployment

Flutter Assemble > Build Settings > macOS Deployment Target

谈情不如逗狗 2025-02-21 02:03:32

在Xcode中打开 macOS 文件夹,然后在项目导航器中选择 pods 。选择框架目标,然后选择一般选项卡。

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

Open the macos folder in Xcode and select Pods in the project navigator. Choose the framework target and select the General tab.

Change this Deployment Target in the pods and save the changes that will resolve that issue

汐鸠 2025-02-21 02:03:32

在我的情况下,我能够通过编辑MACOS/PODFILE并将第一行替换为所需版本的10.15来更改MACOS部署目标版本。

像这样:

platform :osx, '10.15'

I was able to change the macOS deployment target version by editing the macos/Podfile and replacing the first line to the required version 10.15 in my situation.

Like so:

platform :osx, '10.15'
淡莣 2025-02-21 02:03:32

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

另外,请备份您的项目并运行

pod install-repo-update

“

In xcode select the target then select build settings. Make sure it displays the combined options. Check valid architecture. Remove architecture which you arent using.

Also please take a back up of yhe project and run

pod install --repo-update

preview

辞旧 2025-02-21 02:03:32

在这里,我设法通过做两件事来解决它:

  1. 让扑动自动更新目标为10.14(因此,在podfile中,平台更改为10.14)

  2. 使用 Flutter Pub升级

Here I managed to solve it by doing two things:

  1. Letting flutter update the target automatically to 10.14 (so, in the Podfile, platform was changed to 10.14)

  2. Upgrading all dependencies using flutter pub upgrade.

小忆控 2025-02-21 02:03:32

我通过使用Xcode更改部署目标来解决问题。这是键:

在Xcode不 MacOS 中打开文件夹 macos/pods

您必须在 macos/跑步者和 macos/pods pods中设置目标。

I solved the problem by changing the deploy target using Xcode. Here is the key:

Open the folder macos/Pods in Xcode not macos.

You have to set the target both in the macos/ Runner, and the macos/Pods Pods.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文