The Xamarin debugger stuck until eternity
This short post explains how to fix the “xamarin ios waiting for debugger to connect on port 10000 via usb” issue and get your debugger working again.
On-device Debugging Wanted
Every mobile developer knows that you need to run and debug your app on an actual device to make sure that things are working as expected.
Wether it is the Anroid Emulator or the iOS simulator; they can only go so far on simulating the actual target environment of physical devices.
And when things DO go wrong (your solution rarely compiles and runs without any mistake) it really helps when you can debug on your device.
When you’ve grabbed your favorite drink and spun up the debug session, it can be extremely frustrating when the following happens with your Xamarin iOS project:
- project building…. finished 😁
- deploying to device …. 10..20..30………..100% 👌🏻
- The top status bar is showing you the following message:
- 😅 okay, i’ll wait a few seconds
- you wait for a minute… status remaining the same: it appears to be stuck
As it appears, the debugger can’t hook up with your iOS device, and won’t let you step through your code.
This bug seems to be occurring when you’re trying to debug via USB as well. Obviously, the error will then show up as follows:[crayon-60059257172a3040464837/]
Meanwhile, on the device, you can use the app as expected but debugging is not possible.
Fixing the Infinite Wait
Somehow, this issue is caused by the build on the device not properly reacting to the message that Visual Studio is sending over on the default debugging port (which is port 10000).
The app lanches, but things are not communicating conform expectations of the debugging protocol.
In order to fix this from happening again, here are the basic steps that you should follow:
- Remove the app from your iOS device
- In Visual Studio For Mac go and clean your solution (Build > Clean All)
- Right click on your iOS project and select “Reveal in Finder”, and delete the bin and obj directories
- Close Visual Studio entirely
- Restart your iOS device (it depends on your device how you need to do this, check Apple’s instructions if you don’t know how to do it)
- While your phone is rebooting, you can spin up Visual Studio For Mac, open up your solution and rebuild your Xamarin.iOS project
- As soon as your phone is ready and loaded, Build and Run your project on the device
- This time, the deployed application instance should hook up nicely with Visual Studio for Mac once again
- Debug and do your thing 🎉
The steps I mention in this post assume you’re running a project that is using the default debugging configuration for Xamarin.iOS projects.
If you’re still running into issues, check:
- the debug settings on your project via: Right click on your iOS project > Options >iOS Debug. Enable debugging should be checked for your configuration (debug > iPhone)
- check and see that you are actually trying to run the debug version (not the release)
- check that the debug information is set to “Full” for your projecrt via: Right click on your iOS project > Options > Compiler
I hope these instructions saved you some time defeating the “Xamarin iOS waiting for debugger to connect on port 10000 via USB” message.
At least the origin for this bug (for once) isn’t because you:
a) set up something wrong or
b) put an awful and/or weird line of code in your project
These things tend to consume way too much time because we coders often tend to think it’s definitely a or b.
Don’t lose your spirits and keep up with building another awesome solution that provides value!
Code hard, Ship harder!
This post is also published on Medium