Group Group Group Group Group Group Group Group Group

How to check value in xCode

I am new to xCode .I want to figure out one of the basic function set breakpoint and check value. I was surprise that xCode don’t show the value (see picture )and I also want to know how to watch a variable.

I’m not a sophisticated Xcode debugger. Mostly I use print. :face_with_hand_over_mouth: :shushing_face:

You can watch variables: https://www.hackingwithswift.com/example-code/xcode/what-are-watchpoints

but for me the failures are more than the successes, so I do a didSet on the variable and print out the value.

For example, in chapter 5 you might want to watch the rotation of the camera’s viewmatrix. I tried to set a watch on Renderer’s view matrix, but it’s lazy storage and wouldn’t work. So I went to Camera.rotation and in the didSet, I printed out _viewMatrix. That now prints out every time the rotation changes.

Because that works for me, I haven’t really bothered to learn all the LLDB debugging you can do.

There is an entire book on debugging. It’s currently Swift 4.2 and Xcode 10, so I don’t know what’s changed since then. https://store.raywenderlich.com/products/advanced-apple-debugging-and-reverse-engineering

Btw, in the debug console, with that breakpoint, as well as setting the watch, you can print out a description, which should give you the value.

Haha, :+1: This book is so advanced, I think I could read it after I’m done with the metal book.

thanks for these resources, I finally finished chapter 5 ,wow! :tada:

1 Like

Hii, @thetealpickle here :tada:

In Xcode, you can edit breakpoints (right-click on the breakpoint) adding advanced capability to debugging with breakpoints. From variable watching and logging to pausing after 5 reps, and other finer tooth feats.

Edit your breakpoint by right clicking on the breakpoint

1 Like

@relaxslow Hope the debugging tips were helpful! Glad to hear you’re making progress on the book. I have yet to read it myself but from the sounds of it it’s full of valuable info. Another debugging tip I’d thought I’d share is while running your project, you can hover over a variable of your choice which would then a value associated with that property. It can come in handy when you’re figuring out why something might be nil.

Best,
Gina

thank you , but my problem is I can not check the value when I set break point. It just show nothing . Not all of them but always , under some situation It happens but I don’t know why