Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what should I do to change the MACOSX_DEPLOYMENT_TARGET when build flutter macos app

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.

like image 561
Dolphin Avatar asked Sep 07 '25 15:09

Dolphin


2 Answers

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!

like image 137
s21 Avatar answered Sep 10 '25 15:09

s21


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

like image 31
CNK Avatar answered Sep 10 '25 14:09

CNK