iOS Advanced Debugging Using po

It’s not just for printing objects

Photo by Bill Oxford on Unsplash

In iOS, po is typically used in lldb (Low-Level Debugger) to print an object. Recently, however, a friend showed me that po can do much more than that (Disclaimer, I am an Android Dev, learning this is blowing my mind!). Check it out.

Dynamically Fade the App into the Background

I have a simple App below that is nothing more than a simple label. Using po, I can trigger it to fade away.

To do so, upon launching the App, click Ctrl+Cmd+Y to enter a paused mode where the lldb terminal is shown.

In the terminal, we just need to add the following code (Objective-C).

(lldb) po [UIView animateWithDuration:3 animations:^void (void) { [[[[[[UIApplication sharedApplication] delegate] window] subviews] firstObject] setAlpha:(double)0]; }]

Next, type c in the lldb to continue the program. Check the animation. If it didn’t start automatically, click on the interface and you should see the screen fade away.

--

--