How to use Objective-C framework in a Swift written iOS part of a flutter plugin

1,095

I suggest you check out starflut package https://pub.dev/packages/starflut. But most likely what you are trying to accomplish has been done more simply for you in another package but if you are totally bent on doing it yourself I think you should try the package

Share:
1,095
Lorenzo Imperatrice
Author by

Lorenzo Imperatrice

During the morning and afternoon, I usually am at the university for study with my colleagues. If I'm not studying or coding is possible to find me take a walk through the streets of Turin or drink hot cocoa in a pastry. I love to play role-playing games with my friends and watch anime and TV series during the evening.

Updated on December 09, 2022

Comments

  • Lorenzo Imperatrice
    Lorenzo Imperatrice over 1 year

    In a Flutter plugin, I would like to use an Objective-C framework in my iOS part written in swift, and after that using it in a Flutter project that uses Swift as iOS language. After some research about it (I'm not an iOS developer) I find out that what I would like to do is possible by importing the header in the file that act as Bridging header between swift and Objective-C, but the bridging header in the flutter plugin is created automatically if use_frameworks! is defined in the Podfile (as far as I know), and I didn't understand how actually import the header from the Objective-C (I think by defining something in the podspec but I don't know) pod in that. In fact, if I try to import something from the Objective-C pod, XCode complains (and the compiler too) about it by saying that it "doesn't find the module with name <framework name>" or that it can't build Objective-C code. If I try to use the framework in an Objective-C plugin I'm able to use it but only if I comment out use_frameworks! from the project Podfile

    At the end, I was wondering if it's possible to use Objective-c external framework in Swift plugin for developing a flutter plugin.

  • Lorenzo Imperatrice
    Lorenzo Imperatrice about 3 years
    Hey Samuel! Thanks for your suggestion, I'll surely have a look at the package but I don't think that it can help, I've 2 questions open on the same argument, and both of those questions has 10+ votes but no answer :( . Unfortunately, the thing that I had to do, was referred to a paid library that just offers native code and nothing more, my hope was to create a plugin from it but I just ended to bind it to the app code!
  • Lorenzo Imperatrice
    Lorenzo Imperatrice over 2 years
    Hi mate thanks for your answer, if you start to receive some upvotes please, ping me in the comments, in this way I'll assign to you the best answer. Unfortunately I'm not able to verify it anymore because I don't code in Flutter from long time now.