Search code examples
flutterxcodeios-simulatorxcode16

Flutter failed to build ios app, unsupported option -G for target


I just updated my macOS to sequoia 15 and subsequently updated Xcode to 16.0. My flutter application was working just before my update but now running on my ios simulator, i get the following error:

Error output from Xcode build:
↳
    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:iOS Simulator, id:11CEC440-4A5D-41D2-8FCA-9D2D245137D7, OS:18.0,
    name:iPhone 16 }
    { platform:iOS Simulator, id:11CEC440-4A5D-41D2-8FCA-9D2D245137D7, OS:18.0,
    name:iPhone 16 }
    ** BUILD FAILED **


Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/tr/yb7b1tfj3674zn3rlk57mf6r0000gn/T/flutter_tools.COssk3/flutt
        er_ios_build_temp_dirTmt5Jl/temporary_xcresult_bundle

    clang: error: unsupported option '-G' for target
    'x86_64-apple-ios15.0-simulator'
    clang: error: unsupported option '-G' for target
    'x86_64-apple-ios15.0-simulator'
    clang: error: unsupported option '-G' for target
    'x86_64-apple-ios15.0-simulator'

If i run some of my other applications, there arent any errors and it runs successfully. It's only this app that has this error :/

The initial error I got was IPHONEOS_DEPLOYMENT_TARGET not within acceptable version range of 12.0-18.09 but i fixed that with:

config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'

But now im getting the error above. I also didn't have to define this config.buildsettings with my other projects. They all have similar packages and have a specified ios version of 12.0.

I've also done the following:


flutter pub cache clean

flutter pub cache repair

flutter pub get

pod install

Solution

  • Steps to Resolve the Issue:

    step-1: Update cocoa pods-

    sudo gem install cocoapods
    
    pod repo update
    

    Step-2 :

    cd ios
    rm -rf Pods
    rm -rf ~/Library/Developer/Xcode/DerivedData/*
    pod cache clean --all
    

    Step-3: then add those codes in Podfile file.

    just replace this

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

    with this

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
        if target.name == 'BoringSSL-GRPC'
          target.source_build_phase.files.each do |file|
            if file.settings && file.settings['COMPILER_FLAGS']
              flags = file.settings['COMPILER_FLAGS'].split
              flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' }
              file.settings['COMPILER_FLAGS'] = flags.join(' ')
            end
          end
        end
      end
    end
    

    step-4:

    do that

     flutter clean
        flutter pub get 
        cd ios
        pod repo update
        pod install
    

    After that, build clean and then build again in Xcode.

    step-5:

    • Select a runner from TARGETS

    • On the row select Build Settings and search for and set it to yes

      ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES