How to View Value of Swift "Let" Constant in Xcode 6 Debugger

How to view value of Swift let constant in Xcode 6 debugger

This was a bug in Xcode which I can confirm was fixed in Xcode 6.1. (Thanks, Steve Rosenberg.)

This is what I get now, as expected:

screenshot of console; p, po, and fr v now all display the value of someConstant in some way or another

The constant is now displayed correctly in the variables view as well, and is no longer listed twice:

screenshot of variables view; someVariable shows 6 and someConstant shows 5

Xcode Beta 2 - How can I see the values on swift strings in the debugging window

If you set a breakpoint in your code you can print any variable with the po command like this:

(lldb) po myString
"hello"

How to change a let value while debugging in Xcode?

The problem is that the compiler might analyze the let constant at compile time and then optimize your code. For example, think of something like:

func x() -> String {
let doit = false
if (doit) {
return "Yes"
} else {
return "No"
}
}
// ...
let result = x()

A clever compiler will change this to

func x() -> String {
return "Yes"
}
// ...
let result = x()

or even throw away the call of x() completely:

    let result = "Yes"

Hence, there is no doit constant at all, expecially there is no return "No" branch in your program any more.
This is an extreme example, and the compiler typically will do so only in release mode, but you can see that it's not easy to allow constants to be changed during debugging, because the compiler might have to revert some opimizations.

How to debug member variable (ie., Array, Dictionary) in LLDB?

Finally resolved my issue by changing Enable Clang Module Debugging in Apple LLVM 7.1 Language Modules as following screen shot

Enable Clang Module Debugging

Reference : https://stackoverflow.com/a/36176158/4014369

How to use Code value in the info.plist file xcode ios

You can create the variable by adding it as a "User-Defined Setting" to your target, in Build Settings. You can then set the variable value to different things for each of your build configurations.

Please see attached screenshot. You can ignore my Beta Prod and Beta Test configurations, as they probably don't apply to your situation.

Sample Image

CGPoint, NSTimeInterval not showing value on debugger view

This seems to be a bug. I have filed it to Apple under bug #23266337, they have marked it as duplicate for bug #23088739



Related Topics



Leave a reply



Submit