flutter-ml / google_ml_kit_flutter

A flutter plugin that implements Google's standalone ML Kit
MIT License
907 stars 709 forks source link

pod install failed for google_mlkit_translation when building for iOS #637

Closed ZakarY2HM6f closed 1 month ago

ZakarY2HM6f commented 1 month ago

error from CocaPods when flutter run, pod install or pod update

[!] CocoaPods could not find compatible versions for pod "GoogleMLKit/Translate":
  In Podfile:
    google_mlkit_translation (from `.symlinks/plugins/google_mlkit_translation/ios`) was resolved to 0.11.0, which depends on
      GoogleMLKit/Translate (~> 6.0.0)

Specs satisfying the `GoogleMLKit/Translate (~> 6.0.0)` dependency were found, but they required a higher minimum deployment target.

already tried flutter clean, pod cache clean --all no matter how much i increase the deployment target (tried 17.0), the error doesn't do away.

github example builds successfully, but i cannot find the difference between that and my current project. please send help.

my Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

# 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', '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 Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end

# version requirements by ML Kit
$iOSVersion = '12.0'

post_install do |installer|
  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)

    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',
        'AUDIO_SESSION_MICROPHONE=0'
      ]
    end

    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

output of flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.1, on macOS 14.4.1 23E224 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.88.0)
[✓] Connected device (3 available)
    ! Error: Yat Hung’s Apple Watch needs to connect to determine its availability. Check the connection between the device and its companion
      iPhone, and the connection between the iPhone and Xcode. Both devices may also need to be restarted and unlocked. (code 1)
    ! Error: Browsing on the local area network for Zachary’s Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)
[✓] Network resources

• No issues found!
ZakarY2HM6f commented 1 month ago

using google_mlkit_commons: ^0.7.1 google_mlkit_text_recognition: ^0.13.0 google_mlkit_translation: ^0.11.0

when reverting to google_mlkit_commons: ^0.6.1 google_mlkit_text_recognition: ^0.11.0 google_mlkit_translation: ^0.9.0

everything works, so probably something wrong with the new version?

cdiaz-dev commented 1 month ago

Set the following: platform :ios, '12.0'

to: platform :ios, '15.0'

fbernaly commented 1 month ago

Have you tried this: https://github.com/flutter-ml/google_ml_kit_flutter/blob/develop/packages/example/ios/Podfile#L1

it is in our example app, and also in the READMME

Screenshot 2024-06-03 at 9 23 49 AM

famasf1 commented 1 month ago

might need to add that OP does say this.

no matter how much i increase the deployment target (tried 17.0), the error doesn't do away.

I use platform :ios, '15.5' and got the same issue. I'm using Face Detection and got

google_mlkit_face_detection (from .symlinks/plugins/google_mlkit_face_detection/ios) was resolved to 0.11.0 which depend on GoogleMLKit/FaceDetection (-> 6.0.0)
Specs satisfying the `GoogleMLKit/FaceDetection(= 4.0.0, -> 4.0.0), GoogleMLKit/FaceDetection(-> 6.0.0)` dependency were found, but they required a higher minimum deployment target.

Edit : i found the fix. run pod update will fix the issue.