salkuadrat / learning

The easy way to use Machine Learning Kit in Flutter.
https://pub.dev/packages/learning
MIT License
64 stars 55 forks source link

Fix swift compiler errors #19

Open mityax opened 2 years ago

mityax commented 2 years ago

This fixes various issues the swift compiler complained about when I tried to build my app for iOS. Not sure whether this is due to a new swift version or something else, this was actually the first swift code I ever worked on at all.

Closes #18

rainaakshay commented 2 years ago

Can you please merge this request, I cannot build because it keeps saying No such module 'MLKit'

seth35us commented 2 years ago

@rainaakshay I didn't see that file name in the iOS classes and created it. However, when I try to compile now, I am getting the error: Swift Compiler Error (Xcode): No such module 'MLKitTranslate' in [/learning-master/ios/Classes/SwiftLearningTranslatePlugin.swift:3:7]()

Did you see this error at all?

rainaakshay commented 2 years ago

@seth35us No I didn’t try manually changing the file as it will be overwritten on flutter pub get anyways. @salkuadrat merging this pull request will probably solve all these issues.

mityax commented 2 years ago

@rainaakshay @seth35us yes it does. I'm using the plugin successfully now on iOS and Android.

I'm not sure how actively maintained this is though, the author's last actvitiy was on 23rd Nov. If you need it to work fast, you can just use my fork directly in your pubspec.yaml, until this is merged:

  learning_translate:
    git:
      url: https://github.com/mityax/learning_translate.git
seth35us commented 2 years ago

@mityax Great news that you got it working. I just read your message, so will try it out first thing tomorrow morning. Very much appreciated.

rainaakshay commented 2 years ago

@mityax Can I use your fork for entity extraction as well?

mityax commented 2 years ago

@rainaakshay It wouldn't make a difference, I haven't changed anything there.

seth35us commented 2 years ago

@mityax After commenting everything except translation and object detection, I got the app to run with your code. However, I am getting a missing channel error when trying to do any object detection. Similar issues are #4 and #3. Is the object detection working for you on iOS, or is it not implemented?

The only other package I found to do object detection is tflite and it wouldn't compile for me on iOS.

rainaakshay commented 2 years ago

@mityax Did you get any error like this after your changes?

Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_MLKEntityAnnotation", referenced from:
          objc-class-ref in SwiftLearningEntityExtractionPlugin.o
      "_OBJC_CLASS_$_MLKModelDownloadConditions", referenced from:
          objc-class-ref in SwiftLearningEntityExtractionPlugin.o
      "_OBJC_CLASS_$_MLKEntityExtractionParams", referenced from:
          objc-class-ref in SwiftLearningEntityExtractionPlugin.o
      "_OBJC_CLASS_$_MLKEntityExtractor", referenced from:
          objc-class-ref in SwiftLearningEntityExtractionPlugin.o
      "_OBJC_CLASS_$_MLKEntityExtractionRemoteModel", referenced from:
          objc-class-ref in SwiftLearningEntityExtractionPlugin.o
      "_OBJC_CLASS_$_MLKModelManager", referenced from:
          objc-class-ref in SwiftLearningEntityExtractionPlugin.o
      "_OBJC_CLASS_$_MLKEntityExtractorOptions", referenced from:
          objc-class-ref in SwiftLearningEntityExtractionPlugin.o

I made the changes in SwiftLearningEntityExtractionPlugin.swift just like you did in SwiftLearningTranslatePlugin.swift, but mine keeps throwing this error

mityax commented 2 years ago

@rainaakshay No, I haven't encountered anything like that. I can't help you, I'm afraid

mityax commented 2 years ago

@seth35us I have only used language identification and translation - no idea about the others

fbernaly commented 2 years ago

I noticed that most of the APIs in this plugin are only implemented for Android, and some for iOS, this other plugin works for me: google_ml_kit and has the same functionalities.

rainaakshay commented 2 years ago

@fbernaly This plugin was meant as a substitute for the official google ml kit that you mentioned, since at that time google_ml_kit was missing a lot of ios implementations like entity extraction and text recognition v2. Which were supported in this plugin, it was just not maintained.

fbernaly commented 2 years ago

Great, it is supported now.