Setting Up Your Debugging Environment

When we’re in serious debugging mode, it can sometimes help to make sure our debugging tools are ready to deploy immediately. With that in mind, we are going to set up a special debugging tab with an immersive debugging environment. In programming, being organized is vitally important. It will help our efficiency to have a dedicated space where all of our debugging tools are laid out consistently.

Think of your debugging tab like you would your kitchen. When you go to your kitchen to cook, you can get a recipe started right away because you know where all your tools are. If you didn’t know where to find your measuring cups and the food processor, it would take a lot longer to get something started.

Some developers like to have a dedicated debugging tab. You can create a new tab by pressing T, just as you would in a web browser, but there is a better way to create a dedicated debugging tab.

Joe asks:
Joe asks:
How Do You Get Line Numbers in the Editor?

Maybe you’ve noticed that our screenshots of the breakpoint gutter on the left side of the code editor show line numbers, and you’ve wondered why your Xcode isn’t showing line numbers. We are big fans of showing line numbers. It’s a nice reminder that once one of our files hits 1,000 lines, it’s clearly time to refactor that code. Also, it makes the breakpoint gutter a little wider.

To turn on line numbers, go to Xcode’s preferences and select the Text Editing section. The first check box under the Editing tab is “Line numbers,” and that’s where you can turn them on.

images/debugging/line-numbers-pref.png

While here, there are a number of other preferences you can set, and the Indentation tab lets you stake out your position in the never-ending tabs-vs.-spaces war (although this is also available as a setting on your project as a whole, and the project setting takes precedence over your local preference).

Another useful Xcode preference group is the “Fonts and Colors” group, which features various themes for styling your editor’s color scheme and font sizes.

Choose Xcode > Preferences or press , to access the Preferences window. The third tab from the left is Behaviors. This panel controls all of the behaviors an app will have at each and every stage of its life, along with controlling behaviors present in both automated testing and using OpenGL. Since these skills are a little beyond the scope of a beginner book, we won’t be going over them, but we just wanted you to know they are there for when you want to take your next steps.

We want to make sure that we can see all of our testing tools while we are running and debugging our application. Find the Running section of the list. Instead of just waiting to hit a breakpoint, we want to see the debugger when the app starts, when it pauses, and when it generates output.

Click Starts and look at the options available to us. You will see an option that says “Show tab named empty text box in drop-down menu.” Click the check box to ensure that it is selected. In the text box, name it something appropriate, like Debugging. Lastly, go into the drop-down menu and select Active Window.

The last thing we need to do before moving on to other parts of the run cycle is to make sure our debugger is showing. If we look at the option two below the Show Tab option, we will see one that says “Show debugger with drop-down menu.” Again, click the check box to ensure this option is selected and choose Variables & Console View from the options.

Next, let’s move on in the left column to the behaviors we want when we pause our program. We want to show the debugger with Variables & Console View, but now we also want to select the option above that one, which selects a navigator window to show, and we want the Debug Navigator.

Lastly, in Generates Output make sure that you have it set to show the debugger with Variables & Console View. With all that done, make sure your options look the way they do in the following figure.

images/debugging/preferences-behaviors-panel.png

There! Now we have a handy debugging environment that will always be there for us when we need it. Since this is your debugging environment, make sure you go through and look at all the options you think you might want or need. There is nothing that says everyone must have the same options, so feel free to customize this to suit you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset