flutter-ml / google_ml_kit_flutter

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

Cannot run example app #169

Closed mathschy closed 2 years ago

mathschy commented 2 years ago

Hello,

I am trying to use this plugin for OCR.

I can't run the example app. I just git-cloned this repo, launched an iOS simulator and did flutter run and here is the output:

Xcode's output:
↳
    /Users/mathias/development/flutter/.pub-cache/hosted/pub.dartlang.org/camera
    -0.8.1+3/ios/Classes/CameraPlugin.m:596:13: warning:
    'OSAtomicCompareAndSwapPtrBarrier' is deprecated: first deprecated in iOS
    10.0 - Use atomic_compare_exchange_strong() from <stdatomic.h> instead
    [-Wdeprecated-declarations]
        while (!OSAtomicCompareAndSwapPtrBarrier(old, newBuffer, (void
        **)&_latestPixelBuffer)) {
                ^
    In module 'Darwin' imported from
    /Users/mathias/development/flutter/.pub-cache/hosted/pub.dartlang.org/camera
    -0.8.1+3/ios/Classes/CameraPlugin.m:9:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator15.0.sdk/usr/include/libkern/OSAtomicDepreca
    ted.h:548:6: note: 'OSAtomicCompareAndSwapPtrBarrier' has been explicitly
    marked deprecated here
    bool    OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void
    *__newValue, void * volatile *__theValue );
            ^
    /Users/mathias/development/flutter/.pub-cache/hosted/pub.dartlang.org/camera
    -0.8.1+3/ios/Classes/CameraPlugin.m:806:11: warning:
    'OSAtomicCompareAndSwapPtrBarrier' is deprecated: first deprecated in iOS
    10.0 - Use atomic_compare_exchange_strong() from <stdatomic.h> instead
    [-Wdeprecated-declarations]
      while (!OSAtomicCompareAndSwapPtrBarrier(pixelBuffer, nil, (void
      **)&_latestPixelBuffer)) {
              ^
    In module 'Darwin' imported from
    /Users/mathias/development/flutter/.pub-cache/hosted/pub.dartlang.org/camera
    -0.8.1+3/ios/Classes/CameraPlugin.m:9:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
    m/Developer/SDKs/iPhoneSimulator15.0.sdk/usr/include/libkern/OSAtomicDepreca
    ted.h:548:6: note: 'OSAtomicCompareAndSwapPtrBarrier' has been explicitly
    marked deprecated here
    bool    OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void
    *__newValue, void * volatile *__theValue );
            ^
    2 warnings generated.
    2 warnings generated.
    In file included from
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/MLKVisionImage+FlutterP
    lugin.m:1:
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/GoogleMlKitPlugin.h:45:
    22: warning: unused function 'getFlutterError' [-Wunused-function]
    static FlutterError *getFlutterError(NSError *error) {
                         ^
    1 warning generated.
    In file included from
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/GoogleMlKitPlugin.m:1:
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/GoogleMlKitPlugin.h:45:
    22: warning: unused function 'getFlutterError' [-Wunused-function]
    static FlutterError *getFlutterError(NSError *error) {
                         ^
    1 warning generated.
    In file included from
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/vision/CustomRemoteMode
    lManager.m:1:
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/GoogleMlKitPlugin.h:45:
    22: warning: unused function 'getFlutterError' [-Wunused-function]
    static FlutterError *getFlutterError(NSError *error) {
                         ^
    1 warning generated.
    In file included from
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/MLKVisionImage+FlutterP
    lugin.m:1:
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/GoogleMlKitPlugin.h:45:
    22: warning: unused function 'getFlutterError' [-Wunused-function]
    static FlutterError *getFlutterError(NSError *error) {
                         ^
    1 warning generated.
    In file included from
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/GoogleMlKitPlugin.m:1:
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/GoogleMlKitPlugin.h:45:
    22: warning: unused function 'getFlutterError' [-Wunused-function]
    static FlutterError *getFlutterError(NSError *error) {
                         ^
    1 warning generated.
    In file included from
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/vision/CustomRemoteMode
    lManager.m:1:
    /Users/mathias/code/Google-Ml-Kit-plugin/ios/Classes/GoogleMlKitPlugin.h:45:
    22: warning: unused function 'getFlutterError' [-Wunused-function]
    static FlutterError *getFlutterError(NSError *error) {
                         ^
    1 warning generated.
    ld: warning: directory not found for option
    '-F/Users/mathias/code/Google-Ml-Kit-plugin/example/build/ios/Debug-iphonesi
    mulator/XCFrameworkIntermediates/FirebaseAnalytics/AdIdSupport'
    ld: warning: directory not found for option
    '-F/Users/mathias/code/Google-Ml-Kit-plugin/example/build/ios/Debug-iphonesi
    mulator/XCFrameworkIntermediates/GoogleAppMeasurement/AdIdSupport'
    ld: framework not found FirebaseAnalytics
    clang: error: linker command failed with exit code 1 (use -v to see
    invocation)
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in parallel

Could not build the application for the simulator.
Error launching application on iPhone SE (1st generation).

The error seems to be ld: framework not found FirebaseAnalytics (why does it need FirebaseAnalytics by the way ? seems unrelated to google_ml_kit ?)

Here is my flutter doctor

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-arm, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.62.0)
[✓] Connected device (1 available)

How do you manage to run the example app ?

jdiazgon55 commented 2 years ago

Hello @mathschy, were you able to run it on iOS? I am facing a problem on a previous step. I created an issue #194

fbernaly commented 2 years ago

Try the latest version.

Also note that google_ml_kit has been split in multiples plugins, to avoid adding unnecessary dependencies to your project.

More details here:

You can find more details on why you those issues here: