Problem Description

When building Flutter iOS applications, you may encounter the following error:

Error (Xcode): unsupported option '-G' for target 'arm64-apple-ios10.0'

This error can be particularly frustrating as it may appear to be network-related, but connectivity is rarely the actual cause of this issue.


Root Cause

This error is caused by the BoringSSL-GRPC library, which is a common dependency in Flutter iOS projects. The issue occurs when the BoringSSL library attempts to use compiler flags that are incompatible with certain iOS target architectures, specifically when targeting ARM64 devices with iOS 10.0 or later. The error is not related to internet connectivity despite what many online resources suggest. Changing network connections will not resolve this issue.


Solution

To fix this error, you need to modify your project's Podfile to remove the problematic compiler flags from the BoringSSL-GRPC target.

  1. Locate Your Podfile
    • Navigate to your Flutter project's iOS directory:
    • yourproject/ios/Podfile
  2. Add the Fix to Your Podfile
    • Find the post_install section in your Podfile, specifically the line:
      • installer.pods_project.targets.each do |target|
    • Add the following code immediately after this line:
      • 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
  3. Complete Podfile Example
    • Your post_install section should look similar to this:
    • post_install do |installer|
        installer.pods_project.targets.each do |target|
          # Add the BoringSSL-GRPC fix here
          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
          
          # Other Flutter build settings
          flutter_additional_ios_build_settings(target)
        end
      end


  4. Clean and Rebuild
    • After modifying your Podfile:
    • # Complete project cleanup
      flutter clean
      rm -rf ios/Podfile.lock
      rm -rf ios/Pods
      rm -rf ios/Runner.xcworkspace
      rm -rf ios/.symlinks
      
      # Fresh rebuild
      flutter pub get
      cd ios && pod install
      cd .. && flutter build ios --no-codesign


Why This Solution Works

The fix works by:

  1. Targeting the specific problematic library: BoringSSL-GRPC
  2. Removing incompatible compiler flags: Specifically the -GCC_WARN_INHIBIT_ALL_WARNINGS flag that causes conflicts with ARM64 targets
  3. Preserving other necessary flags: Only removing the problematic flag while keeping others intact


Troubleshooting

If you continue to experience issues:

  1. Verify Xcode version compatibility with your Flutter version
  2. Check for conflicting pods that might also modify compiler flags
  3. Ensure your iOS deployment target is compatible with your dependencies


Interested in MacinCloud Managed Servers?

Visit the Managed Server Plan page to obtain a Managed server.


Do you require full root/admin privileges on a MacinCloud Server?

Find out more about MacinCloud Dedicated Server Plans
.