当我在Xcode 7.3.1(使用标准Swift 2编译器)中运行我的Swift应用程序并且执行在断点处暂停时,我无法使用po
命令检查变量。第一次运行po exists
(exists
在当前范围内是非可选的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)
我解决了这个问题。问题是我正在重新定义现有协议:
protocol MyCustomStringConvertible {}
extension MyCustomStringConvertible where Self: RawRepresentable, Self.RawValue == String {
..
}
我重新定义了CustomStringConvertible协议,或者当我编写自己的版本时,Apple的CustomStringConvertible可能不存在。该协议可能仅po
在调试时使用,因此该错误永远不会在运行时出现。
我唯一的疑问是:编译器是否应提醒我重新定义现有协议?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句