my flutter engine.profiler (52): EXC_BAD_ACCESS (code=EXC_I386_GPFLT) in swift

179 views Asked by At

I need to call the flutter engine all time .So I given the code as below.

In the appdelegate.h file

@property (nonatomic,strong) FlutterEngine *flutterEngine;

In the appdelegate.m file

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    self.flutterEngine = nil;

    //Flutter module initialization
    self.flutterEngine = [[FlutterEngine alloc] initWithName:@"my flutter engine"];
    // Runs the default Dart entrypoint with a default Flutter route.
    [self.flutterEngine run];
    // Used to connect plugins (only if you have plugins with iOS platform code).
    [GeneratedPluginRegistrant registerWithRegistry:self.flutterEngine];
    
}

Then HomeVC.m file

 FlutterEngine *flutterEngine = ((IKAppDelegate *)UIApplication.sharedApplication.delegate).flutterEngine;
    
         if (flutterEngine != nil) {
     
         }
    
        flutterEngine = nil;
        flutterEngine = [[FlutterEngine alloc] initWithName:@"my flutter engine"];
        [flutterEngine  run];
        [GeneratedPluginRegistrant registerWithRegistry:flutterEngine];
        FlutterViewController *flutterViewController = [[FlutterViewController alloc]initWithEngine:flutterEngine nibName:nil bundle:nil];
        FlutterMethodChannel* moduleChannel = [FlutterMethodChannel
                                               methodChannelWithName:@"com.ikea.kompis/nativeToFlutter"
                                               binaryMessenger:flutterViewController.binaryMessenger];
        [moduleChannel invokeMethod:@"nativeToFlutter"
                          arguments: jsonString
        ];
       flutterViewController.modalPresentationStyle = UIModalPresentationFullScreen;
       // [self presentViewController:flutterViewController animated:YES completion:nil];

    [self presentViewController:flutterViewController animated:YES completion:nil];

But getting as crash. my flutter engine.3.profiler (52): EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

this can happen at any time .So how can fix this issuse

0

There are 0 answers