google_ml_kit_flutter icon indicating copy to clipboard operation
google_ml_kit_flutter copied to clipboard

Definition of 'MLKText' must be imported from module 'MLKitTextRecognitionCommon.MLKText' before it is required

Open sinshev opened this issue 5 years ago • 36 comments

When building on iOS I am getting 5 errors:

  1. "Declaration of 'MLKTextRecognizedLanguage' must be imported from module 'MLKitTextRecognitionCommon.MLKTextRecognizedLanguage' before it is required"
  2. "Definition of 'MLKText' must be imported from module 'MLKitTextRecognitionCommon.MLKText' before it is required"
  3. "Definition of 'MLKTextBlock' must be imported from module 'MLKitTextRecognitionCommon.MLKTextBlock' before it is required"
  4. "Definition of 'MLKTextLine' must be imported from module 'MLKitTextRecognitionCommon.MLKTextLine' before it is required"
  5. "Definition of 'MLKTextElement' must be imported from module 'MLKitTextRecognitionCommon.MLKTextElement' before it is required"

I've tried both 0.6.0 and 0.7.0 versions of the plugin. flutter clean does not help.

sinshev avatar Aug 14 '21 20:08 sinshev

I am also getting this issue. I'm on an M1 Mac if that helps.

dustin-graham avatar Aug 14 '21 23:08 dustin-graham

Same issue here, on flutter v2.2.3 stable, on Mac OS X 10.15.7.

minamax1994 avatar Aug 15 '21 10:08 minamax1994

@minamax1994 , are you also on a Mac M1 chip?

dustin-graham avatar Aug 15 '21 18:08 dustin-graham

  • Declaration of 'MLKTextRecognizedLanguage' must be imported from module 'MLKitTextRecognitionCommon.MLKTextRecognizedLanguage' before it is required
  • Definition of 'MLKText' must be imported from module 'MLKitTextRecognitionCommon.MLKText' before it is required
  • Definition of 'MLKTextBlock' must be imported from module 'MLKitTextRecognitionCommon.MLKTextBlock' before it is required
  • Definition of 'MLKTextLine' must be imported from module 'MLKitTextRecognitionCommon.MLKTextLine' before it is required
  • Definition of 'MLKTextElement' must be imported from module 'MLKitTextRecognitionCommon.MLKTextElement' before it is required

Same issue here, using MacBook Air M1 and google_ml_kit: ^0.7.0

montmany avatar Aug 15 '21 20:08 montmany

Same issue here, I try flutter clean , delete Podfile, Podfile.lock, Pods/, .symlinks . I try used iOS and google_ml_kit : ^0.5.0, ^0.6.0 and ^0.7.0. Five days ago (11.08.2021) working good but since last Thursday (12.08.2021) become not working....

canibal1 avatar Aug 16 '21 07:08 canibal1

@minamax1994 , are you also on a Mac M1 chip?

@dustin-graham Not sure, I'm using AppCenter for generating builds.

minamax1994 avatar Aug 16 '21 08:08 minamax1994

same issue 🚑 🚑 🚑

LebranD avatar Aug 16 '21 12:08 LebranD

Ok, I did some digging and experimenting this morning and found some interesting things.

My podfile.lock says that I'm depending on MLKitTextRecognition (1.4.0-beta1):

In that version of the dependency, MLKitTextRecognition.h looks like this:

#import "MLKTextRecognizer+Latin.h"
#import "MLKTextRecognizerOptions.h"

1.4.0-beta1 is actually Text Recognition V2. In the latest version of V1, 1.3.0, MLKitTextRecognition.h looks like this:

#import "MLKText.h"
#import "MLKTextBlock.h"
#import "MLKTextElement.h"
#import "MLKTextLine.h"
#import "MLKTextRecognizedLanguage.h"
#import "MLKTextRecognizer.h"

The code in this repository is written assuming the older, non-beta version of MLKit. So the question is, why are we now getting this incorrect dependency, regardless of what version of this plugin we use. @canibal1 , thanks for trying all those other versions, that was actually the key to figuring this out.

It turns out that the podspec for this repo includes unbounded dependencies on MLKit. So when Google released 1.4.0-beta1 on 8/11/21, all new pod installations pulled in 1.4.0 and broke this plugin.

https://github.com/bharat-biradar/Google-Ml-Kit-plugin/blob/aabc7eb2b98a2db07f3eca40648e28fb35162c9a/ios/google_ml_kit.podspec#L24

I was able to fix this issue locally. I'm going to go make a PR to fix this this morning.

dustin-graham avatar Aug 16 '21 16:08 dustin-graham

Ok, I did some digging and experimenting this morning and found some interesting things.

My podfile.lock says that I'm depending on MLKitTextRecognition (1.4.0-beta1):

In that version of the dependency, MLKitTextRecognition.h looks like this:

#import "MLKTextRecognizer+Latin.h"
#import "MLKTextRecognizerOptions.h"

1.4.0-beta1 is actually Text Recognition V2. In the latest version of V1, 1.3.0, MLKitTextRecognition.h looks like this:

#import "MLKText.h"
#import "MLKTextBlock.h"
#import "MLKTextElement.h"
#import "MLKTextLine.h"
#import "MLKTextRecognizedLanguage.h"
#import "MLKTextRecognizer.h"

The code in this repository is written assuming the older, non-beta version of MLKit. So the question is, why are we now getting this incorrect dependency, regardless of what version of this plugin we use. @canibal1 , thanks for trying all those other versions, that was actually the key to figuring this out.

It turns out that the podspec for this repo includes unbounded dependencies on MLKit. So when Google released 1.4.0-beta1 on 8/11/21, all new pod installations pulled in 1.4.0 and broke this plugin.

https://github.com/bharat-biradar/Google-Ml-Kit-plugin/blob/aabc7eb2b98a2db07f3eca40648e28fb35162c9a/ios/google_ml_kit.podspec#L24

I was able to fix this issue locally. I'm going to go make a PR to fix this this morning.

I am very happy that the problem has been resolved. It saved me from a great burden. :)

canibal1 avatar Aug 16 '21 19:08 canibal1

I merged this PR: https://github.com/bharat-biradar/Google-Ml-Kit-plugin/pull/118. Does that fix your issue?

fbernaly avatar Aug 16 '21 21:08 fbernaly

I merged this PR: #118. Does that fix your issue?

Yes, I tried a couple minute ago. It's working very well. Just add pubspec.yaml file this git adress like that

 google_ml_kit:
    git:
      url:https://github.com/dustin-graham/Google-Ml-Kit-plugin 

and go ios file then,

delete Podfile delete Podfile.lock delete Pods/ delete .symlinks flutter clean Pub get and run project. Happy build debug and compiles 😄

canibal1 avatar Aug 16 '21 21:08 canibal1

@canibal1 : flutter run works but building on iOS through xCode fails , getting the below issue :

Undefined symbol: _MLKPoseLandmarkTypeRightWrist Undefined symbol: _MLKPoseLandmarkTypeRightThumb Undefined symbol: _MLKPoseLandmarkTypeRightKnee

Any clue how to fix this ? @dustin-graham

luvishq avatar Aug 19 '21 15:08 luvishq

@luvishq , I'm not sure about that. I'm not seeing that on my end. Just to make sure we have a good starting point. Make sure you do a flutter clean. In xcode clean the build folder. Delete the pods folder. Then run a pod get, and run again.

Beyond that I'm not sure. Take a closer look at the error and see where it's happening. Can you provide more information about the error?

dustin-graham avatar Aug 20 '21 05:08 dustin-graham

@dustin-graham : I tried the above but it failed again, it seems there are some undefined symbols , Please see attached screenshot for the build error I am getting :

Screen Shot 2021-08-22 at 9 48 45 PM

luvishq avatar Aug 23 '21 04:08 luvishq

@luvishq I had the same problem. A deletion of the Podfile.lock, flutter clean and cleaning derived data folder helped in my case. Of course, also checking out the fix PR as mentioned above by @canibal1.

nachtmaar avatar Aug 24 '21 16:08 nachtmaar

Honestly im so so annoyed and im so angry why can't I make this package work ! :(

developer-farhan avatar Aug 25 '21 10:08 developer-farhan

Launching lib/main.dart on iPhone 12 in debug mode... Running pod install... Running Xcode build... Xcode build done. 12.5s Failed to build iOS app Error output from Xcode build: ↳ objc[50997]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1fd2dfad8) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1140882b8). One of the two will be used. Which one is undefined. objc[50997]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1fd2dfb28) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x114088308). One of the two will be used. Which one is undefined. ** BUILD FAILED **

Xcode's output: ↳ Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:91:26: error: declaration of 'MLKTextRecognizedLanguage' must be imported from module 'MLKitTextRecognitionCommon.MLKTextRecognizedLanguage' before it is required languages:(NSArray<MLKTextRecognizedLanguage *> *)languages ^ In module 'MLKitTextRecognition' imported from /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:3: In module 'MLKitTextRecognitionCommon' imported from /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognition/Frameworks/MLKitTextRecognition.framework/Headers/MLKTextRecognizer+Latin.h:4: /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognitionCommon/Frameworks/MLKitTextRecognitionCommon.framework/Headers/MLKTextRecognizedLanguage.h:7:12: note: declaration here is not visible @interface MLKTextRecognizedLanguage : NSObject ^ /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:28:41: warning: 'textRecognizer' is deprecated: Please use textRecognizer(options:) instead. [-Wdeprecated-declarations] textRecognizer = [MLKTextRecognizer textRecognizer]; ^ In module 'MLKitTextRecognition' imported from /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:3: /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognition/Frameworks/MLKitTextRecognition.framework/Headers/MLKTextRecognizer+Latin.h:21:5: note: 'textRecognizer' has been explicitly marked deprecated here __deprecated_msg("Please use textRecognizer(options:) instead."); ^ In module 'UIKit' imported from /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/Target Support Files/google_ml_kit/google_ml_kit-prefix.pch:2: In module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8: In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6: In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/usr/include/sys/cdefs.h:200:48: note: expanded from macro '__deprecated_msg' #define __deprecated_msg(_msg) attribute((deprecated(_msg))) ^ /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:40:42: error: definition of 'MLKText' must be imported from module 'MLKitTextRecognitionCommon.MLKText' before it is required textResult[@"text"] = visionText.text; ^ In module 'MLKitTextRecognition' imported from /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:3: In module 'MLKitTextRecognitionCommon' imported from /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognition/Frameworks/MLKitTextRecognition.framework/Headers/MLKTextRecognizer+Latin.h:4: /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognitionCommon/Frameworks/MLKitTextRecognitionCommon.framework/Headers/MLKText.h:9:12: note: definition here is not reachable @interface MLKText : NSObject ^ /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:47:33: error: definition of 'MLKTextBlock' must be imported from module 'MLKitTextRecognitionCommon.MLKTextBlock' before it is required cornerPoints:block.cornerPoints ^ In module 'MLKitTextRecognition' imported from /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:3: In module 'MLKitTextRecognitionCommon' imported from /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognition/Frameworks/MLKitTextRecognition.framework/Headers/MLKTextRecognizer+Latin.h:4: /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognitionCommon/Frameworks/MLKitTextRecognitionCommon.framework/Headers/MLKTextBlock.h:11:12: note: definition here is not reachable @interface MLKTextBlock : NSObject ^ /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:57:36: error: definition of 'MLKTextLine' must be imported from module 'MLKitTextRecognitionCommon.MLKTextLine' before it is required cornerPoints:line.cornerPoints ^ In module 'MLKitTextRecognition' imported from /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:3: In module 'MLKitTextRecognitionCommon' imported from /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognition/Frameworks/MLKitTextRecognition.framework/Headers/MLKTextRecognizer+Latin.h:4: /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognitionCommon/Frameworks/MLKitTextRecognitionCommon.framework/Headers/MLKTextLine.h:11:12: note: definition here is not reachable @interface MLKTextLine : NSObject ^ /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:67:43: error: definition of 'MLKTextElement' must be imported from module 'MLKitTextRecognitionCommon.MLKTextElement' before it is required cornerPoints:element.cornerPoints ^ In module 'MLKitTextRecognition' imported from /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/vision/TextRecognizer.m:3: In module 'MLKitTextRecognitionCommon' imported from /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognition/Frameworks/MLKitTextRecognition.framework/Headers/MLKTextRecognizer+Latin.h:4: /Users/farhan/AndroidStudioProjects/ml_advice_app/ios/Pods/MLKitTextRecognitionCommon/Frameworks/MLKitTextRecognitionCommon.framework/Headers/MLKTextElement.h:13:12: note: definition here is not reachable @interface MLKTextElement : NSObject ^ 1 warning and 5 errors generated. In file included from /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/GoogleMlKitPlugin.m:1: /Users/farhan/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_ml_kit-0.7.0/ios/Classes/GoogleMlKitPlugin.h:40:22: warning: unused function 'getFlutterError' [-Wunused-function] static FlutterError *getFlutterError(NSError *error) { ^ 1 warning generated. note: Using new build system note: Building targets in parallel note: Planning build note: Analyzing workspace note: Constructing build description note: Build preparation complete

Could not build the application for the simulator. Error launching application on iPhone 12.

developer-farhan avatar Aug 25 '21 10:08 developer-farhan

it works on android but when I run here it throws error I have never been able to make ML kit work on IOS please someone help me I even to padlock and changed the following

- MLKitTextRecognition (~> 1.4.0-beta1)

to

  • MLKitTextRecognition (~> 1.3.0)

nothing works

My app is a simple default flutter counter app and package is not running

developer-farhan avatar Aug 25 '21 10:08 developer-farhan

@luvishq I had the same problem. A deletion of the Podfile.lock, flutter clean and cleaning derived data folder helped in my case. Of course, also checking out the fix PR as mentioned above by @canibal1.

@dustin-graham @nachtmaar : Still getting the same error :/

luvishq avatar Aug 25 '21 14:08 luvishq

@luvishq I had this additional error message: "building for iOS Simulator-x86_64 but attempting to link with file built for iOS Simulator-arm64".

Do you also have a Mac with arm chip ?

if yes, these commands helped:

rm -r /Users/<your-user>/Library/Developer/Xcode/DerivedData/*
flutter clean
flutter pub get
cd ios
pod install
cd ..
flutter run

nachtmaar avatar Aug 28 '21 17:08 nachtmaar