iosfluttergoogle-mlkit

Failed to build iOS app when I add Google MLkit Barcode Scanning


I create an application Flutter with a barcode scanner. I want to use Google ML Kit but when I add the plugin google_mlkit_barcode_scanning, I can build Android app but the iOS app failed to build.

I have this error :

enter image description here

I try to change Exclude Architecture like this : enter image description here

And the podfile like this :

platform :ios, '12.0'  # or newer version

...

# add this line:
$iOSVersion = '12.0'  # or newer version

post_install do |installer|
  # add these lines:
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "armv7"
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
  end
  
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    
    # add these lines:
    target.build_configurations.each do |config|
      if Gem::Version.new($iOSVersion) > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
      end
    end
    
  end
end

But nothing works.

I try to launch example from this : https://github.com/flutter-ml/google_ml_kit_flutter/tree/develop/packages/example and it's work but I don't find the difference between my code and example code.

thanks :)


Solution

  • I solved my problem by adding this code to the ios/Podfile :

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
        target.build_configurations.each do |config|
          config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
          config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
        end
      end
    end