Swift LLDB fail

when i use po, alway show this error.


(lldb) po viewModel
error: warning: Failed to load linked library UIKit of module Login - errors:
Looking for "@rpath/UIKit.framework/UIKit", error: (null)
Failed to find framework for "UIKit" looking along paths:
 /Users/name/Library/Developer/Xcode/DerivedData/Game-fbcssrnefpcutjgjoxicuabsatne/Build/Products/Debug-iphoneos/UIKit.framework/

Looking for "/Users/name/Library/Developer/Xcode/DerivedData/MegabilityInterface-hiqhsjxojjhqgudnbcwzmovnxrqu/Build/Intermediates.noindex/ArchiveIntermediates/MegabilityInterface/BuildProductsPath/Release-iphoneos/UIKit.framework/"
,  error: (null)



error: <EXPR>:2:11: error: cannot find type '$__lldb_context' in scope
extension $__lldb_context {
     ^~~~~~~~~~~~~~~

error: <EXPR>:19:5: error: cannot find '$__lldb_injected_self' in scope
  $__lldb_injected_self.$__lldb_wrapped_expr_10(
  ^~~~~~~~~~~~~~~~~~~~~

(lldb) 

I was try setting this config by

  • SWIFT_OPTIMIZATION_LEVEL
  • DEBUG_INFORMATION_FORMAT

Still does't work.

if i use IDE 'Print Description of "viewModel" '


Printing description of viewModel:
(Game.ViewModel) viewModel = <Unable to determine byte size.>

Still error of LLDB?

Accepted Reply

The thing that caught our eye is the UIKit module error, with a file path pointing to the build folder for your app, and this is where we’d like to focus first. I was hoping we’d see some correlating evidence of what’s happening here through the build log, but there wasn’t anything in the build log to assist. The next thing you should do is run the Swift health check LLDB command to assess any issues with the modules referred to by your app. We discuss this command in the following WWDC video: https://developer.apple.com/videos/play/wwdc2022/110370/

Replies

You can try extending your ViewModel to implement the CustomDebugStringConvertible protocol like this:

extension ViewModel : CustomDebugStringConvertible { var debugDescription: String { get { return "a description" } } }

po tries to output the debugDescription so maybe that is what you need.

(But the missing UIKit linked library makes me think it is something completely different)

The thing that caught our eye is the UIKit module error, with a file path pointing to the build folder for your app, and this is where we’d like to focus first. I was hoping we’d see some correlating evidence of what’s happening here through the build log, but there wasn’t anything in the build log to assist. The next thing you should do is run the Swift health check LLDB command to assess any issues with the modules referred to by your app. We discuss this command in the following WWDC video: https://developer.apple.com/videos/play/wwdc2022/110370/