In Xcode's Variables View, on the right of the Debug area, when an app is running and paused at a breakpoint you can right-click a variable and select "Edit Value".
For a swift String it's greyed out, and I can imagine why that might be the case. But even for a simple int, it brings up an edit box to enter an new value, but after hitting the value stays at the old value. This is true even for a var which is changed during the code.
Update: as shown in Jim's answer below, you should be able to set the value using the lldb expression command, but, although Xcode will tell you it has changed, it fails to actually change the value.
Is this broken, or is there something specific you need to do for it to work? Thanks.
Update: It's a compile bug - see Jim's comment. Here's a workaround...
println("Before lldb change, foo is (foo)")
//make compiler think foo may change, so I can change it myself at the console
if count("abcd") == 0 { foo = 0 }
println("After lldb change, code now thinks foo is (foo)")
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…