po Swift String "unresolved identifier"

Errortype520 picture Errortype520 · Jun 19, 2014 · Viewed 9.6k times · Source

I am having trouble debugging Swift Strings

func stringTest() {

    let test1:String =   "test1";
    let test2:NSString = "test2";

    // <-- Breakpoint here

    println(test1);
    println(test2);
}

If I set a breakpoint after these lines and try and print test1 I get the following error:

po test1
error: <REPL>:1:1: error: use of unresolved identifier 'test1'
test1
^

But I am able to print test2 successfully:

po test2
test2

Answer

slamor picture slamor · Aug 23, 2014

It is a bug of Beta. Xcode6-Beta5 has still this bug. You can only get debug info for swift's variables, but can't get it for swift's constants. Temporarily you can change let test1 to var test1 and you will got debug info. Hope this will be fixed in release version. Good Luck in debugging ;)

EDIT: Unfortunately, the same issue is still happening in first release of Xcode Version 6.0.1 (6A317)

let test1:String  -> debug info is unavailable
var test1:String  -> debug info is available

EDIT2: Yes, confirmed. It is fixed also for iOS apps in the latest Xcode 6.1 under OS X Yosemite.