How to import external iOS framework in flutter plugin?
Solution 1
1.Place myFramework.framework
to iOS plugin folder /ios ex: myPlugin/ios
2.Update iOS plugin file: myPlugin/ios/myPlugin.podspec
Adding the below line at the bottom of the file, above 'end'
s.vendored_frameworks = 'myFramework.framework'
In Terminal : cd to myPlugin/example/ios
run command
pod install
or
pod update
Now we can find the iOS plugin code by open iOS project (example/ios/Runner.xcworkspace) in XCode and go to
Solution 2
@Lorenzo you can pack your plugin and make private CocoaPod or Carthage repo. Here is a good article howtos
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, 2022Comments
-
Lorenzo Imperatrice over 1 year
I'm doing a flutter plugin for stream video by using RTSP protocol. I had no problem develop it for Android, but in iOS things are more complex. I have to use an external library (SGPlayer) for getting the player work. I also downloaded the demo that uses this library and seems to work. This library is NOT on Cocoapods and I need to import it directly into the plugin project from my file system. the downloaded and compiled file structure of the plugin that I would like to use looks like this:
My problem is adding the ".framework" extension file correctly to the iOS project in a way that I can use it to develop the flutter plugin (iOS part).
UPDATE: I built the project with the framework by using instructions at this link: https://github.com/flutter/flutter/issues/17978
The problem now is that while compiling the framework it change the umbrella header because, I think, it's not using the framework module.modulemap but another one. The result is that is importing just some header and implementations, and not all.
-
Lorenzo Imperatrice over 5 yearsFirst of all, thanks for the answer! I have a new question, at the moment, to get things works, I had to import the local framework by using the script that I found in the Github page that I had mentioned in my answer update. The problem is that I had to remove the
use_frameworks!
from the Podfile and now is impossible for me use Swift Pod if I would like to, but if I leave it, and I try to run the app I get a lot of errors. At this point, my question is: Is possible to use Objective-c pod in a Swift plugin? and how .podspec and Podfile settings are? -
Nihad Delic almost 4 yearsHey, but what is IDEA behind creating private CocoaPod repo? I should create private CocoaPod and how then to connect my local .framework with that CocoaPod repo?