Xamarin.iOS – Using Debug WriteLine

In this lesson

  • Use Intellisense to import class definition
  • Use compiler if statements to detect running in debug
  • Use Application Output panel to see traces
1:26 C# 100


Tap on time to skip ahead


I want to make sure I’m in the right place. I’m going to say Debug.WriteLine(“Hello”) You’ll notice this is all red, that’s because the compiler doesn’t know what Debug is. If I hit command return, you’ll see the compile error. If I hit option return, you get this nice little Intellisense from Xamarin Studio that offers some potential ways to resolve this issue. If I select Using System.Diagnostics, you’ll see it adds this up here at the top of my file.


This basically lets the compiler know, “hey, we’re using System Diagnostics and Debug is a feature of System.Diagnostics.” I’ll just go ahead and show this. I can say, “if debug, then do this.” And it will only run this code if debug is selected up here. If I select release it won’t run that code. It’s kind of a handy feature, a little bit advanced.


If I rerun this again, if we take a look in our application output down here in the lower left, we’ll see our Hello. We know for sure that, hey, we’re in the right spot code wise.