LLDB (Swift): Casting Raw Address into Usable Type

Under Xcode 8.2.1 and Swift 3, the lldb command po or p won’t work with the typed variable. You will need to use the swift command print to examine the properties of the typed object instance. (Thanks to cbowns’s answer!) E.g.:

expr -l Swift -- import UIKit
expr -l Swift -- let $pin = unsafeBitCast(0x7df67c50, to: MKPinAnnotationView.self)
expr -l Swift -- print($pin.alpha)

Leave a Comment