Change Variables On The Fly While Debugging With XCode and LLDB

Somewhere around Xcode 4.3 lldb became the default debugger. I’ve been spending some time learning how lldb differs from gdb and stumbled upon a trick to allow changing the value of a variable while in a breakpoint.

For example, in the code below I print the value of testStr, I then change its value using the expr command in lldb, I then print the value of the string again:

NSString *testStr = @"fubar";
NSLog(@"testStr before: %@", testStr);
// Set breakpoint here, run the 'expr' shown below
// Show testStr again
NSLog(@"testStr after: %@", testStr);

Continue reading

Debug Failed Push Messages By Logging APSD Process

When things are not working as expected with push messages, having insight into what is happening at a deeper level than your code, can be very helpful. iOS offer offers a logging feature that captures APSD process information on the device.

To enable logging of push messages install the configuration profile PersistentConnectionLogging.mobileconfig on your device:

Option #1 – Upload the file to a web-server and point Safari on your phone to the file

Option #2 – Send the file via email and open the attachment

With either option you will receive an alert asking if you are good with installing APS/PC Logging.

Continue reading

Collection of Objective-C Debugging Macros

In a previous post, Yet Another Debug Output Replacement, I wrote a macro that I prefer over NSLog as the output does not prepend the date/time and object information as does NSLog.

For example, the debug macro in the earlier post shows output as shown in the final line below, which (in my opinion) is much easier to read over the line that displays the default date and time information:

I thought I would pass along a few more macros that I use on a regular basis for printing debug information on rectangles, points and sizes. I’ve also included a means to turn debug information on/off so debug statements are not included in builds targeted as final releases.

Continue reading

Xcode Debugging: Going Back in Time

This tip is based on information in the book Xcode 3 Unleashed. I just completed a three part review the book, which you can read here.

When inside a debugger and stepping through code, line be line, have you ever wanted to move to the top of a loop and restart, including resetting counters, without having to restart the application/debugger? Here’s a cool trick you can use within Xcode to do just that. In the figure below, notice that the current value of the variable name is America/Antigua.
Continue reading