by Hwee-Boon Yar — Subscribe to tips via weekly email

Ever set a breakpoint in a Obj-C project, run this:

(lldb) po UIScreen.mainScreen.bounds

and get:

error: property 'bounds' not found on object of type 'id' error: 1 errors parsing expression

Annoying isn't it?

You can fix this by doing:

(lldb) expr @import UIKit

So run po UIScreen.mainScreen.bounds again, and you'd get:

(origin = (x = 0, y = 0), size = (width = 414, height = 736))

But you have to do this manually everything you start a debug session. As a good programmer and fan of automation, you can set a breakpoint and let Xcode do it for you.

Cmd+7 to show the Breakpoints navigator Add a symbolic breakpoint for the symbol UIApplicationMain Add an action for that breakpoint: expr @import UIKit Check that so it automatically continues after evaluating actions

Now every time you run the project, commands such as po UIScreen.mainScreen.bounds will work.

Bonus nugget:

Ctrl-click on your breakpoint in the Breakpoints navigator. Choose Move BreakPoint To , and choose User. This will make the breakpoint available for every Xcode project (enabled by default).





Your feedback is valuable: Do you want more nuggets like this? Yes or No

.

.