SwiftUI names are not demangled
Platform
macOS
Environment
Production
Installed
Swift Package Manager
Version
8.24.0
Did it work on previous versions?
No
Steps to Reproduce
Look at this report: https://sindresorhus.sentry.io/share/issue/0e4faa9089734b2bbe498a1e876fb30e/
In the stack trace:
7SwiftUI4ViewRzlAA15ModifiedContentVyxAA16OnSubmitModifierVGAaBHPxAaBHD1__AfA0cH0HPyHCHCTm 7SwiftUI4ViewRzlAA15ModifiedContentVyxAA21_DefaultFocusModifierVGAaBHPxAaBHD1__AfA0cH0HPyHCHCTm
Expected Result
I expected them to be demangled.
Actual Result
They are not demangled.
Are you willing to submit a PR?
No
Thanks for opening this. It might be related to https://github.com/getsentry/sentry-cocoa/issues/3081.
I dug into this a little bit, and it turns out that when you use Verbose Function Names, both of these are prefixed with get_witness_table , which is being generated right here:
https://github.com/apple/swift/blob/3caef440583aa16ff0164395899b6e87e234f427/lib/IRGen/GenReflection.cpp#L519-L522
Swifts own demangler does not recognize that, as is it does not start with a proper swift mangling prefix. (Admittedly, our demangler is based on Swift 5.5.1 which is a bit out of date)
However, if I replace that with the proper prefix ($s), I get the following:
<A>concrete protocol conformance ModifiedContent<A, OnSubmitModifier>protocol conformance ref (type's module) Viewdependent root protocol conformance #0 AViewconcrete protocol conformance OnSubmitModifierprotocol conformance ref (type's module) ViewModifier<A>concrete protocol conformance ModifiedContent<A, _DefaultFocusModifier>protocol conformance ref (type's module) Viewdependent root protocol conformance #0 AViewconcrete protocol conformance _DefaultFocusModifierprotocol conformance ref (type's module) ViewModifier
That is quite a mouthful, and TBH I have no idea what any of that means.
Long story short, the compiler has to output a proper swift symbol with the proper prefix for it to be demangled properly.
But it might also be related to #3081 as @philipphofmann mentioned, as its quite possible that we just end up trying to demangle the name of some static data table because we lack access to proper debug symbols.
If I got it right @Swatinem, except from doing https://github.com/getsentry/sentry-cocoa/issues/3081 there isn't much we can do right now, except to wait for Apple to provide proper dSYMs for SwiftUI?
Indeed, we need to have a proper dSYM, otherwise its hard to move forward on any of this.