[swift-dev] [Feature request] Debug the Swift objects in Objective C frames.

Singh, Deepak Deepak.Singh at dish.com
Thu Jun 8 13:09:12 CDT 2017


Hi,

In various contexts we see objects we know to be Swift, but we only have them as Objective-C object pointers.
For example, in the debugger it is possible to be stopped in Objective-C code, have a local variable of type id or NSViewController*, but the underlying object is a custom view controller implemented in Swift.
Also, users of the Memory Graph Debugger in Xcode, and people looking at logs or output from po of Objective-C objects (such as entries in AppKit responder chains) would benefit from this feature.

It is possible to inspect the Objective-C view of this type but that does not show all the Swift instance variables, and many methods (such as generic methods) can't be called at all.

One way to solve this would be to provide a Swift standard library API of the form:

func buildObject<T>(fromRawPointer: UInt64) : T

I'd like to get this feature considered for the standard library, potentially with some restrictions:

  *   Since it allows people to violate ARC by storing pointer references to objects, this API might best be restricted to debugger use cases
  *   It might be necessary to restrict T to only be of class type; it might be more difficult to refer to an Int (for example) on the stack

Regards,
Deepak Singh.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20170608/899b6878/attachment.html>


More information about the swift-dev mailing list