ios – MissingPluginException if I work with flutterEngine

ios – MissingPluginException if I work with flutterEngine


I’ve two targets in xcode: One iOS app and one watch App. The AppDelegate inside the iOS App has this code:

 lazy var flutterEngine = FlutterEngine(title: "XXX")
    
    personal var session: WCSession?
    personal var channel: FlutterMethodChannel?
    
    override func utility(
        _ utility: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // Runs the default Dart entrypoint with a default Flutter route.
        flutterEngine.run()
        
        // Watch
        initWatchConnectivity()
        initFlutterChannel()
        
        // Used to attach plugins (solely in case you have plugins with iOS platform code).
        GeneratedPluginRegistrant.register(with: self.flutterEngine)

Its necessary so as to add a FlutterEngine as a result of I work with one other ViewController (Splashviewcontroller with Lottie Animation) as entryPoint.

The SplashViewController Code is that this:

 func startFlutterApp() {
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        let flutterEngine = appDelegate.flutterEngine
        let flutterViewController =
        FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
        
        appDelegate.window?.rootViewController = flutterViewController

        
    }

However now my MethodChannel from Flutter shouldn’t be working anymore. I get:

Unhandled Exception: MissingPluginException(No implementation discovered for technique forwardToAppleWatch on channel xxx.xxx.xxx.watchkitapp)

Plainly it loses the MethodChannel perform from the appDelegate whereas the brand new ViewController is introduced.

With out the SplashViewController the MethodChannel is working completely, within the watch goal as nicely. How can I work with an additional view just like the splash controller and the MethodChannel on the identical time?

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.