How to Debug Xamarin Application on Visual Studio

Xamarin is an amazing technology for cross-platform mobile application development. Now, iOS developers can build and debug iOS applications in Windows machines, using Visual Studio. The new Xamarin Live Player allows creating, running, testing, and debugging iOS apps directly from a Windows PC that runs Visual Studio. Earlier, you needed a Mac to build and test your apps.

To get started with this new feature, you just need to install the Xamarin Live Player app on the iOS device and then pair it to your PC by scanning a QR code on your screen. Since it is fully baked into Virtual Studio; you also get access to all of the standard functionality you would prefer in your IDE. You can do a lot more including make live edits to your code while it is running and immediately see the result of a color change, etc

Using the Xamarin Live Player, you can preview XAML naturally and easily. MVC Dot Net Visual Studio will automatically give you the glances of the active XAML document as you move from document to document. Also, it includes other features like breakpoints when debugging, and integration with the Console and Error windows. And also sometimes you may start a project with certain platforms in mind, so it also offers the option to select a particular platform of your targeted app. Below are the steps to debug the Xamarin application on Visual Studio :

Setting Breakpoints

https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/debugging-in-xamarin-ios-images/debugging1.png

By clicking the Breakpoints pad, you can view all the breakpoints that have been set in your code

Image source: https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/debugging-in-xamarin-ios-images/image0a.png

If the Breakpoints pad is not displaying automatically, you need to make it visible, to do so, and click View > Debug Windows > Breakpoints

Always remember to set the configuration to Debug, before you start debugging any application. This will always good to use handy tools to support debugging including breakpoints, using data visualizers, and viewing the call stack.

Start Debugging

Image Source: https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/debugging-in-xamarin-ios-images/debugging7b.png

Once you are done choosing the device, deploy your application by pressing the Play button. When you click a breakpoint, you can see the highlighted yellow color code.

You can use debugging tools, like inspecting the values of objects, at this point to know more about what is happening in your code:

Conditional Breakpoints

Steps to set a conditional breakpoint :

• To add a new conditional breakpoint, you can access the breakpoint properties window by right-clicking on the editor margin, to the left of the line number for the code you would like to set a breakpoint on and choose New Breakpoint:

• Right-click the breakpoint and choose Breakpoint Properties to set a condition to an existing breakpoint.

2. You can then enter the condition under which you want to a breakpoint to occur:

Image Source: https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/debugging-in-xamarin-ios-images/image6.png

Navigating through code

Breakpoints

So, setting breakpoints to startup code is quite not possible, you can use some other form of callback method that can be executed after Finished Launching has terminated.

Device Diagnostics

Wireless Debugging

For more information on Wireless Debugging, You can visit the Wireless Deployment guide.

Technical Details

Accessing the Console

On the other hand, you can also go to Apple’s iPhone Configuration Utility to directly access the console if you do not wish to start up Xcode.

Debugging Mono’s Class Libraries

Team4solution.com stands amongst the most popular mobile app & web development companies in USA