LLDB error: type for self cannot be reconstructed: type for typename

All is fine in Xcode15, no LLDB errors whatsoever, but in Xcode16 I can't get any variable displayed in the console because of the following error:

error: type for self cannot be reconstructed: type for typename "$......." was not found (cached)
error: Couldn't realize Swift AST type of self. Hint: using `v` to directly inspect variables and fields may still work.

I've checked the output of swift-healthcheck and there are several messages like this:

SwiftASTContextForExpressions(module: "ROA", cu: "ROA+ViewLayer.swift")::LoadOneModule() -- Missing Swift module or Clang module found for "UIKit", "imported" via SwiftDWARFImporterDelegate. Hint: Register Swift modules with the linker using -add_ast_path.

I added -add_ast_path to the OTHER_LDFLAGS in the faulty module's build settings but no luck.

How can I debug my project in Xcode16?

What's unique about the ROA+ViewLayer.swift file? Does that file reference UIKit types but is missing an import declaration? And if you look at the ROA module, how is it built in terms of frameworks it references, its dependencies, its use of UIKit, and so on? If you were to place that module into a brand new Xcode project and reference it from the new project, do you get the same results from the health check?

— Ed Ford,  DTS Engineer

Sorry, this Xcode16 just sucks. I've lost another half a days fiddling around with no luck, I just don't know what to do, and where. The project is big and in order to recreate the functionality, and the lldb bug, I have to build a whole new project, which will end up resembling the original one, minus some functionalities, so I dropped this route.

The issue appears in one of the projects's internal static library. Now, I pause the execution at some breakpoint, run the "po" command and promptly get the "Couldn't realize Swift AST type of self". Then I run "swift-healthcheck", check the health log file, find the error below and conclude that the issue is in the static lib "***".

SwiftASTContextForExpressions(module: "***", cu: "AllParts.swift")::LoadOneModule() -- Missing Swift module or Clang module found for "***", "imported" via SwiftDWARFImporterDelegate. Hint: Register Swift modules with the linker using -add_ast_path.

Then I added "-add_ast_path" on the "Other Linker Flags" of the final executable, and now I get an error in Xcode saying "Unknown argument -add_ast_path". The static lib build settings have no "Other Linker Flags", and I don't know where else I should add this flag?!

I mention that the I get a message in the console warning about empty dSYM file, but the executable is built with "DWARF with dSYM File", I triple checked it.

warning: (arm64) /Users/SomeUser/Library/Developer/Xcode/DerivedData/SW-ajoovsaqjdvysgbbrebnfmoxycwm/Build/Products/Debug-maccatalyst/SW.app/Contents/MacOS/SW empty dSYM file detected, dSYM was created with an executable with no debug info.

I'm not sure what you are asking here "Does that file reference UIKit types but is missing an import declaration?". Yes, it uses UIKit types but there is an "import UIKit" directive at the begining of the file where the breakpoint is.

How is this static library that you've identified built? Is it a static library target (i.e. building from source through a reference in your project), or is it a pre-built binary? And if it's pre-built, was it built as an XCFramework? Finally, is this library all Swift, or does it have a mix of C languages and headers too?

—Ed Ford,  DTS Engineer

There are 3 projects in a workspace. The main project and two separate projects for two static libraries. Both static libs depend on a framework, a regular framework not a XCFramework. Everything is built from scratch, I own all the source code. The code for the framework is in a swift module.

I set "DWARF with dSYM" on all the three projects, it was DWARF only for the libs, but no luck.

I can debug the source code from the main project, it works just fine. However, the two static libraries contain the majority of the functionality and I can't debug it. I was adding logs here and there but it takes a lot of time.

Are you able to share your project in this state (or a trimmed down one that demonstrates the same issue) with us? If so, I'd like you to do so via a bug report. That way, I can take a look at it to see if there's something you can do to improve your debugging outcomes here, and if there's a bug here that we need to investigate, then all of the info from you is in the right place for us to do so. If that's feasible for you, just post the FB number of your report here for my reference.

— Ed Ford,  DTS Engineer

@Razvan, you said:

Hey Ed, just encountered the same issue on Xcode 16.2 It seems this error shows up only when trying to debug SwiftUI-related structs.

It would be helpful if you could file a bug report with something in a reproducible Xcode project that we can look at, and determine both wha the issue is, as well as find anything that you can do in your project to improve your debugging output. If you're able to do so, please post the FB number here.

— Ed Ford,  DTS Engineer

I've encountered the same problem. May I ask if it has been solved?

Written by yasoyyyy in 824466022
May I ask if it has been solved?

I haven't yet seen a bug report with a reproducible case, as I was hoping to get from the above conversation. Xcode 16.3 beta is available, so you can download and test it to see if you continue to see the same behaviors. And if you do, perhaps you'll be able to file the bug report that contains the reproducible case so we can understand what's happening here? (Please post the FB number if you do.)

— Ed Ford,  DTS Engineer

Xcode 16.3 beta (16E5104o) exhibits the same issue.

LLDB error: type for self cannot be reconstructed: type for typename
 
 
Q