Finally I got a custom Flutter Plugin's MethodChannel to do the hello-world.

But now, I would like to add a dependency explicitly to the iOS part of the Plugin Class (obviously not to the Android-part...).

However, this somehow bites the snake in its tale since the Plugin Class is itself part of the Flutter Pod. So how does this work ?

I added the following inside the /iOS/Podfile

target 'Runner' do

  pod `MyPodDependency`

The code compiles.

But the import MyPodDependency fails. (inside my Plugin Class where I also program the public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {...} code, to be found under ../Pod/../../../../ios/Classes/MyPluginClass.swift)

My question: How do I import MyPodDependency inside the iOS part of the Flutter Plugin-Class?

In which of the Podfiles do I need to add my pod.

Can I use any imported Framework inside the Plugin Class (where the FlutterMethodCall's handle method sits)? And if yes, how ???

Solution 1: dcg

You have to remember that a plugin must work in any project, not only in yours. This is why its dependencies shouldn't be inside your project's pod file, but contained in its own dependencies file, otherwise, everyone would always have to add manually each dependency of all the plugins used in a project.

That said, your plugin dependencies must be referenced inside the .podspec file, located in the /ios directory of your plugin. This will execute when you run "pod install" in your project, fetching all external dependencies your plugin needs. If you take a look in the existing file, it already presents one dependency:

s.dependency 'Flutter'

Follow the example and add your other plugin dependencies below.

Finally, you will have to add the plugin to your Flutter project. Simply add it to the pubspec file, as you would do with all other plugins.