Hello ladies and gentlemen, Leo here. Today we’ll start to talk about one option to help you debug your iOS and Swift code. Today we will debug iOS with LLDB starting using the PO command.

First a brief explanation of what is the LLDB.

LLDB is a next-generation, high-performance debugger. It is built as a set of reusable components which highly leverage existing libraries in the larger LLVM Project, such as the Clang expression parser and LLVM disassembler. [The project link](https://lldb.llvm.org)

LLDB is the default debugger in Xcode on macOS and supports debugging C, Objective-C, and C++ on desktop and iOS devices and simulators.

Debug iOS using PO command

Let’s explore one thing you can use to debug in LLDB, the command:

> You have a breakpoint and a very complex class/struct with a lot of attributes or want to know what is the value of an Nth item in a collection.

First, you’ll have to put a breakpoint somewhere in the scope you’re looking for. Then, when the breakpoint stops the app you will be able to see on the console the LLDB line has appeared. In the example below we are trying to inspect what is the name of the 9384 in runtime. You can inspect any attribute or variable within the scope. This is really useful because with just one breakpoint you can get ALL information you need to debug!

Now you just put what are you looking for, in this case

po personList[9384] //the 9384th person in the list

and…

You can use the de PO command for anything you want to get from your scope. So the next time you are debugging, you can use this tool to help you to get everything you need to achieve your goal!

This is just a tiny tiny bit of the LLDB power and we’ll continue to share more useful commands in future posts.

Summary

Today we learned how to use PO command to improve your debugging skills in iOS.

That’s all my people, I hope you liked reading this article as much as I enjoyed writing it. If you want to support this blog you can Buy Me a Coffee or leave a comment saying hello. You can also sponsor posts and I’m open to freelance writing! You can reach me on LinkedIn or Twitter and send me an e-mail through the contact page.

Thanks for the reading and… That’s all folks.

Credits: image