Search code examples
visual-studiocordovaremote-debuggingvisual-studio-cordova

Visual Studio hangs when remote debugging a Cordova iOS app


I use Visual Studio 2013 with 'Tools for Apache Cordova'. In the settings page 'Remote Agent Configuration' of the Cordova tools, I enabled the iOS remote processing.

During remote debugging of an iOS Cordova app, Visual Studio hangs when I set a breakpoint to inspect a result of a cordova plugin. I then need to restart Visual Studio.

A breakpoint on a line which is executed before calling a Cordova plugin works without problems... Also storing the result of a Cordova plugin in a variable and then inspecting it using another click event handler works.

Does someone else also notice this problem? Could you fix it?


Solution

  • I had the same issue with self-written plugins.

    Try to let your plugin run in a background thread. Then debugging should work without problems. Look at the following code snippet:

    - (void)myMethod:(CDVInvokedUrlCommand*)command
    {
           NSString* callbackId = command.callbackId;
    
           [self.commandDelegate runInBackground:^{
                 // your plugin logic comes here
    
                 // successful plugin execution
                 CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"success"];
                 [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
           }
    
           return;
    }