Thursday, August 2, 2012

I can't debug on device!


My app won't connect to MonoDevelop when debugging on device, what do I do?



Here are a few tips to track down this particular failure:


  • Switch between USB and WiFi mode. Just go to MonoDevelop's Preferences and toggle this check box:



  • Enable diagnostic output when the app tries to connect to MonoDevelop. This is done by adding "-v -v -v" to the additional mtouch arguments in your project's options:



    Now rebuild your app, and you should get more information on what's happening in the iOS Device Log:

    MonoTouch: Added IP to look for MonoDevelop: 123.123.123.123
    MonoTouch: MonoDevelop Port: 10000 Transport: USB
    MonoTouch: Successfully received USB connection from MonoDevelop on port 10000, fd: 5
    MonoTouch: Processing: 'connect output'
    MonoTouch: Successfully received USB connection from MonoDevelop on port 10000, fd: 6
    MonoTouch: Processing: 'start debugger: sdb'
    MonoTouch: Debugger loaded with custom transport (fd: 6)
    MonoTouch: Successfully received USB connection from MonoDevelop on port 10000, fd: 7
    MonoTouch: Processing: 'start profiler: no'
    

    Some of this information should also (but probably won't since that's the problem you're trying to solve in the first place) show up in MonoDevelop's Application Output pad (everything after the 'connect output' line, since that's when the app's standard output is redirected to MonoDevelop):

    Please ensure your device is connected...
    Connected to: Rolf Bjarne Kvinge’s iPad
    Killed the process 'instruments' with pid 1287.
    Launching /private/var/mobile/Applications/06007ED7-84C1-4D67-A893-7C04CE477F15/instruments.app -debugtrack -monodevelop-port 10000 -connection-mode usb
    
    MonoTouch: Successfully received USB connection from MonoDevelop on port 10000, fd: 6
    MonoTouch: Processing: 'start debugger: sdb'
    MonoTouch: Debugger loaded with custom transport (fd: 6)
    MonoTouch: Successfully received USB connection from MonoDevelop on port 10000, fd: 7
    MonoTouch: Processing: 'start profiler: no'
    
    Loaded assembly: /private/var/mobile/Applications/06007ED7-84C1-4D67-A893-7C04CE477F15/instruments.app/Mono.Security.dll
    Loaded assembly: /private/var/mobile/Applications/06007ED7-84C1-4D67-A893-7C04CE477F15/instruments.app/System.dll
    Loaded assembly: /private/var/mobile/Applications/06007ED7-84C1-4D67-A893-7C04CE477F15/instruments.app/System.Core.dll
    Loaded assembly: /private/var/mobile/Applications/06007ED7-84C1-4D67-A893-7C04CE477F15/instruments.app/monotouch.dll
    Loaded assembly: /private/var/mobile/Applications/06007ED7-84C1-4D67-A893-7C04CE477F15/instruments.app/MonoTouch.Dialog-1.dll
    Loaded assembly: /private/var/mobile/Applications/06007ED7-84C1-4D67-A893-7C04CE477F15/instruments.app/instruments.exe
    Thread started: Finalizer
    
    

    This time everything connected fine, but if error messages may be printed to the iOS Device Log if anything goes wrong.

  • Restart your device and machine.
  • Last solution: file a bug or ask on the MonoTouch mailing list. Please remember to include the information you got from the previous steps, that's the first thing anybody will ask you anyway.