po Swift字符串“未解析的标识符"; [英] po Swift String "unresolved identifier"

查看:80
本文介绍了po Swift字符串“未解析的标识符";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调试Swift字符串时遇到问题

I am having trouble debugging Swift Strings

func stringTest() {

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

    // <-- Breakpoint here

    println(test1);
    println(test2);
}

如果我在这些行之后设置了一个断点并尝试打印test1,则会出现以下错误:

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
^

但是我能够成功打印test2:

But I am able to print test2 successfully:

po test2
test2

推荐答案

这很可能是调试信息输出中的错误.您可以通过例如从register read pc抓住PC,然后执行以下操作来检查这一点:

This is most likely a bug in the debug information output. You can check this by grabbing the PC, for instance from register read pc, and then doing:

(lldb) image lookup -va <PC VALUE>

这将打印一堆东西,但是最后一个条目将是调试器当前可见的所有变量,以及它们在何处(在寄存器或内存中).如果您在此处看不到该变量,则进行调试信息必须告诉lldb该变量当前不可用.

That will print a bunch of stuff, but the last entries will be all the variables currently visible to the debugger, and where they live (in registers or memory.) If you don't see the variable there, then the debug information must have told lldb that the variable is not currently live.

如果您可以在一些示例代码中重现此代码,则可以使用该代码,请向bug report.apple.com提交错误.

If you can reproduce this in some example code you can make available, please file a bug with bug reporter.apple.com.

这篇关于po Swift字符串“未解析的标识符";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆