使用Xcode 7.3.1无法在我的Swift 2项目中使用“po”检查变量 - 错误加载帮助函数

问题描述 投票:8回答:2

当我在Xcode 7.3.1(使用标准Swift 2编译器)中运行我的Swift应用程序并在断点处执行暂停时,我无法使用po命令检查变量。我第一次运行po existsexists是当前范围内的非可选Bool变量)我得到一个很长的错误消息(见下文)。从第二次开始运行相同的命令,我收到error loading helper function: (null)消息。

应用程序在调试方案上编译和运行,没有“部署后处理”和无[-O0]优化。

变量内容在Xcode的变量检查器面板中正确显示。

po self或在设备和iOS模拟器上运行的任何其他变量都会出现相同的错误。

如果我运行一个新的干净项目,使用po进行调试可以正常工作。


在目前的范围内:

var exists: Bool = self.canRemoveAttachmentForEpisode(episode)
NSLog("Exists is now \(exists)") // Breakpoint is set here

这是调试器面板中发生的情况:

po exists
error loading helper function: <EXPR>:141:9: warning: '--' is deprecated: it will be removed in Swift 3
        --maxItemCounter
        ^~
                         -= 1
<EXPR>:237:14: warning: '++' is deprecated: it will be removed in Swift 3
            i++
             ^~
              += 1
<EXPR>:267:19: warning: 'init(start:end:)' is deprecated: it will be removed in Swift 3.  Use the '..<' operator.
        let rng = Range(start: si, end: ei.advancedBy(-1))
                  ^
<EXPR>:280:9: warning: initialization of variable '$__lldb_error_result' was never used; consider replacing with assignment to '_' or removing it
    var $__lldb_error_result = __lldb_tmp_error
    ~~~~^~~~~~~~~~~~~~~~~~~~
    _
<EXPR>:89:41: error: 'CustomStringConvertible' is ambiguous for type lookup in this context
                    if let csc = (x as? CustomStringConvertible) {
                                        ^~~~~~~~~~~~~~~~~~~~~~~
Swift.CustomStringConvertible:13:17: note: found this candidate
public protocol CustomStringConvertible {
                ^
Castamatic.CustomStringConvertible:1:17: note: found this candidate
public protocol CustomStringConvertible {
                ^
<EXPR>:101:41: error: 'CustomStringConvertible' is ambiguous for type lookup in this context
                    if let csc = (x as? CustomStringConvertible) {
                                        ^~~~~~~~~~~~~~~~~~~~~~~
Swift.CustomStringConvertible:13:17: note: found this candidate
public protocol CustomStringConvertible {
                ^
Castamatic.CustomStringConvertible:1:17: note: found this candidate
public protocol CustomStringConvertible {
                ^


(lldb) 



(lldb) po exists
error loading helper function: (null)

(lldb) 
ios xcode swift debugging
2个回答
2
投票

我解决了这个问题。问题是我正在重新定义现有协议:

protocol MyCustomStringConvertible {}

extension MyCustomStringConvertible where Self: RawRepresentable, Self.RawValue == String {
   ..
}

我重新定义了CustomStringConvertible协议,或者当我编写自己的版本时,Apple的CustomStringConvertible可能不存在。可能该协议仅在调试时由po使用,因此错误永远不会在运行时出现。

我唯一的疑问是:编译器是否应该提醒我重新定义现有协议?


1
投票

我有类似的问题,但有不同的解决方案。我在这个链接中使用了这个解决方案:https://stackoverflow.com/a/32984193/2060180

我会留在这里,以防它对某人有用。

© www.soinside.com 2019 - 2024. All rights reserved.