问题
ok what changed in xCode7 / Swift that I can no longer use "po frame" to view the contents of a CGRect anylonger? The print statment works just fine in the code. How come I can't view that in the debugger console like I used to?
var frame = self.myLabel.frame
frame.origin.x = self.startingFrame.origin.x + translation.x
frame.origin.y = self.startingFrame.origin.y + translation.y
print(frame)
self.myLabel.frame = frame
yet in the debugger if I break on the self.myLabel.frame = frame statement and use po (or p or print) in the debugger I get:
(164.0, 323.0, 41.6666666666667, 20.3333333333333)
(lldb) po frame
error: <EXPR>:1:1: error: use of unresolved identifier 'frame'
frame
^~~~~
(lldb) p frame
error: <EXPR>:1:1: error: use of unresolved identifier 'frame'
frame
^~~~~
(lldb) print frame
error: <EXPR>:1:1: error: use of unresolved identifier 'frame'
frame
^~~~~
(lldb)
回答1:
This is a bug in Xcode 7.1. It is fixed in the current 7.2 beta, and will be fixed in the final. The bug is that the types for Structs imported from C/ObjC modules into Swift are not available to the debugger (and in turn it won't report variables whose types are unavailable.)
回答2:
I am still seeing this in Xcode 7.2 (using ObjC). Makes it very frustrating debugging layout code.
The debugger doesn't show the frame as an ivar of the views and type summaries won't print it. You have to 'po foo.frame' to see it.
来源:https://stackoverflow.com/questions/33215765/what-changed-in-xcode7-debugger-that-i-can-no-longer-view-variables-with-po