skip to Main Content

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.

4

Answers


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

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. 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!

    Login or Signup to reply.
  4. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search