google_ml_kit_flutter
google_ml_kit_flutter copied to clipboard
google_mlkit_image_labeling and google_mlkit_text_recognition not working for Firebase hosted models
Describe the bug
Using packages google_mlkit_image_labeling: ^0.4.0
and google_mlkit_text_recognition: ^0.4.0
with custom Firebase hosted ML models fails on pod install
Getting different kinds of errors, like so:
[!] CocoaPods could not find compatible versions for pod "FirebaseInstallations":
In Podfile:
GoogleMLKit/LinkFirebase was resolved to 3.1.0, which depends on
MLKitLinkFirebase (~> 2.1.0) was resolved to 2.1.0, which depends on
FirebaseInstallations (~> 8.0)
firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) was resolved to 12.0.3, which depends on
Firebase/Messaging (= 9.4.0) was resolved to 9.4.0, which depends on
FirebaseMessaging (~> 9.4.0) was resolved to 9.4.0, which depends on
FirebaseInstallations (~> 9.0)
CocoaPods could not find compatible versions for pod "GoogleMLKit/MLKitCore":
In Podfile:
GoogleMLKit/LinkFirebase was resolved to 0.60.0, which depends on
GoogleMLKit/MLKitCore (= 0.60.0)
google_mlkit_text_recognition (from `.symlinks/plugins/google_mlkit_text_recognition/ios`) was resolved to 0.4.0, which depends on
GoogleMLKit/TextRecognition (~> 3.1.0) was resolved to 3.1.0, which depends on
GoogleMLKit/MLKitCore (= 3.1.0)
CocoaPods could not find compatible versions for pod "MLKitCommon":
In Podfile:
google_mlkit_text_recognition (from `.symlinks/plugins/google_mlkit_text_recognition/ios`) was resolved to 0.4.0, which depends on
GoogleMLKit/TextRecognition (~> 3.1.0) was resolved to 3.1.0, which depends on
GoogleMLKit/MLKitCore (= 3.1.0) was resolved to 3.1.0, which depends on
MLKitCommon (~> 7.0.0)
google_mlkit_text_recognition (from `.symlinks/plugins/google_mlkit_text_recognition/ios`) was resolved to 0.4.0, which depends on
GoogleMLKit/TextRecognition (~> 3.1.0) was resolved to 3.1.0, which depends on
MLKitTextRecognition (~> 1.4.0-beta5) was resolved to 1.4.0-beta5, which depends on
MLKitCommon (~> 7.0)
google_mlkit_text_recognition (from `.symlinks/plugins/google_mlkit_text_recognition/ios`) was resolved to 0.4.0, which depends on
GoogleMLKit/TextRecognition (~> 3.1.0) was resolved to 3.1.0, which depends on
MLKitTextRecognition (~> 1.4.0-beta5) was resolved to 1.4.0-beta5, which depends on
MLKitVision (~> 4.1) was resolved to 4.2.0, which depends on
MLKitCommon (~> 8.0)
CocoaPods could not find compatible versions for pod "MLKitTextRecognitionCommon":
In Podfile:
google_mlkit_text_recognition (from `.symlinks/plugins/google_mlkit_text_recognition/ios`) was resolved to 0.4.0, which depends on
GoogleMLKit/TextRecognition (~> 3.1.0) was resolved to 3.1.0, which depends on
MLKitTextRecognition (~> 1.4.0-beta5) was resolved to 1.4.0-beta5, which depends on
MLKitTextRecognitionCommon (= 1.0.0-beta5)
google_mlkit_text_recognition (from `.symlinks/plugins/google_mlkit_text_recognition/ios`) was resolved to 0.4.0, which depends on
GoogleMLKit/TextRecognitionJapanese (~> 3.1.0) was resolved to 3.1.0, which depends on
MLKitTextRecognitionJapanese (~> 1.0.0-beta5) was resolved to 1.0.0-beta6, which depends on
MLKitTextRecognitionCommon (= 1.0.0-beta6)
CocoaPods could not find compatible versions for pod "MLKitVision":
In Podfile:
google_mlkit_commons (from `.symlinks/plugins/google_mlkit_commons/ios`) was resolved to 0.2.0, which depends on
MLKitVision
google_mlkit_image_labeling (from `.symlinks/plugins/google_mlkit_image_labeling/ios`) was resolved to 0.4.0, which depends on
GoogleMLKit/ImageLabeling (~> 3.1.0) was resolved to 3.1.0, which depends on
MLKitImageLabeling (~> 2.1.0) was resolved to 2.1.0, which depends on
MLKitVisionKit (~> 5.1) was resolved to 5.1.0, which depends on
MLKitObjectDetectionCommon (~> 4.1) was resolved to 4.2.0, which depends on
MLKitVision (~> 4.2)
google_mlkit_text_recognition (from `.symlinks/plugins/google_mlkit_text_recognition/ios`) was resolved to 0.4.0, which depends on
GoogleMLKit/TextRecognition (~> 3.1.0) was resolved to 3.1.0, which depends on
MLKitTextRecognition (~> 1.4.0-beta5) was resolved to 1.4.0-beta5, which depends on
MLKitVision (~> 4.1)
Steps to reproduce
Try to use the package google_mlkit_image_labeling: ^0.4.0
, adding the additional required setup for hosting Firebase models.
Podfile:
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
# Enable firebase-hosted models #
pod 'GoogleMLKit/LinkFirebase'
pod 'Firebase'
# 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__))
end
# add this line:
$iOSVersion = '10.0'
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
target.build_configurations.each do |config|
# Enable firebase-hosted ML models
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'MLKIT_FIREBASE_MODELS=1',
]
end
end
end
pubspec.yaml
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.17.6 <3.0.0"
dependencies:
firebase_messaging: ^12.0.3
google_mlkit_image_labeling: ^0.4.0
google_mlkit_text_recognition: ^0.4.0
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
Expected behavior The code is working on android, iOS requires additional setup and it does not work on iOS.
Additional context Add any other context about the problem here.
##Flutter doctor
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.0.5, on macOS 12.1 21C52 darwin-arm, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] VS Code (version 1.71.0) [✓] Connected device (3 available) [✓] HTTP Host Availability
• No issues found!
Flutter dependencies Run flutter pub deps -- --style=compact and paste the output below: Dart SDK 2.17.6 Flutter SDK 3.0.5 temp 1.0.0+1
dependencies:
- firebase_messaging 12.0.3 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- google_mlkit_image_labeling 0.4.0 [flutter google_mlkit_commons]
- google_mlkit_text_recognition 0.4.0 [flutter google_mlkit_commons]
dev dependencies:
- flutter_lints 2.0.1 [lints]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]
transitive dependencies:
- async 2.8.2 [collection meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- characters 1.2.0
- charcode 1.3.1
- clock 1.1.0
- collection 1.16.0
- fake_async 1.3.0 [clock collection]
- firebase_core 1.21.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_core_platform_interface 4.5.1 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 1.7.2 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_messaging_platform_interface 4.1.3 [firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.1.3 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- google_mlkit_commons 0.2.0 [flutter]
- js 0.6.4
- lints 2.0.0
- matcher 0.12.11 [stack_trace]
- material_color_utilities 0.1.4
- meta 1.7.0
- path 1.8.1
- plugin_platform_interface 2.1.2 [meta]
- sky_engine 0.0.99
- source_span 1.8.2 [collection path term_glyph]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- string_scanner 1.1.0 [charcode source_span]
- term_glyph 1.2.0
- test_api 0.4.9 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- vector_math 2.1.2