XCode : Cannot print object in console when debuging - ios

Without any reason, Xcode show an error when i whan ton print using the debuger console :
(lldb) po self
warning: Swift error in scratch context: error: failed to load module 'XXX'
.
Shared Swift state for XXX.app has developed fatal errors and is being discarded.
REPL definitions and persistent names/types will be lost.
error: expression failed to parse:
unknown error
It's an iOS project with cocoapods. I'm on an M1 pro chip.
Any idea ?

I would start with simply print(self) instruction and check what appears in the console.
I like also debug(self) function (prints the whole object hierarchy).
If you want to print thread, you can use Thread.callStackSymbols.forEach { print($0) }
Have you tried set a breakpoint and then browse the Variable List (left side of the Debug Area)?

Related

Xcode po is not printing output in debugging area

Xcode is not giving expected results when i try to print any object. I am using Xcode 12.4 .. In another mac its working fine.
Ex: When i try to print the text inside the UITextField getting below
error
(lldb) po emailTextField.text
expression produced error: error:
/var/folders/5q/9vj8df5s0xs_2splf1fbwgzh0000gn/T/expr39-7ad9b9..swift:1:51:
error: cannot specialize a non-generic definition
Swift._DebuggerSupport.stringForPrintObject(Swift.UnsafePointer<Swift.Optional<Swift.String>>(bitPattern:
0x10ba5a660)!.pointee)
^
/var/folders/5q/9vj8df5s0xs_2splf1fbwgzh0000gn/T/expr39-7ad9b9..swift:1:64:
note: while parsing this '<' as a type parameter bracket
Swift._DebuggerSupport.stringForPrintObject(Swift.UnsafePointer<Swift.Optional<Swift.String>>(bitPattern:
0x10ba5a660)!.pointee)
^
(lldb)
I have tried all the options given in the App Dev answers and tried changing the xcode, still no luck
Spammers stay and Don't spam with your unrelated answers

Xcode Error when launching application Error: Unable to Capture View Hierarchy

I have tried to load the flutter app, that I created, on my phone, but when I try to launch it, it shows a white screen or crashes directly.
The error I am getting is:
Error: Unable to Capture View Hierarchy.
Details: Log Title: Data source expression execution failure.
Log Details: error evaluating expression “(id)[[(Class)objc_getClass("DBGTargetHub") sharedHub] performRequestWithRequestInBase64:#"…"]”: error: <user expression 1>:1:14: use of undeclared identifier 'objc_getClass'
(id)[[(Class)objc_getClass("DBGTargetHub") sharedHub] performRequestWithRequestInBase64:#"YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGvEBMLDBscHR4fICwtLi8wMzk6Oz4/VSRudWxs0w0ODxAVGldOUy5rZXlzWk5TLm9iamVjdHNWJGNsYXNzpBESExSAAoADgASABaQWFxgZgAaAB4ARgBKAEF8QF0RCR0hpZXJhcmNoeVJlcXVlc3RUeXBlXxAcREJHSGllcmFyY2h5UmVxdWVzdFByZWRpY2F0ZV8QHURCR0hpZXJhcmNoeVJlcXVlc3RJZGVudGlmaWVyXxAXREJHSGllcmFyY2h5UmVxdWVzdE5hbWUQAdMNDg8hJhqkIiMkJYAIgAmACoALpCcoKSeADIAOgA+ADIAQXxATZW51bVByb3ZpZGVyQ2xhc3Nlc18QEWluY2x1ZGVMYXp5VmFsdWVzXxATc3RyaWN0ZXN0VmlzaWJpbGl0eV8QFm9wdGlvbnNQcm92aWRlckNsYXNzZXPSDg8xMqCADdI0NTY3WiRjbGFzc25hbWVYJGNsYXNzZXNXTlNBcnJheaI2OFhOU09iamVjdAgQA9I0NTw9XE5TRGljdGlvbmFyeaI8OF8QJEQ4MTE0NkQ2LTY1MjAtNDE4Qy05MjA4LTQ1NDJBQUY5NjFEQ18QD0luaXRpYWwgcmVxdWVzdAAIABEAGgAkACkAMgA3AEkATABRAFMAaQBvAHYAfgCJAJAAlQCXAJkAmwCdAKIApACmAKgAqgCsAMYA5QEFAR8BIQEoAS0BLwExATMBNQE6ATwBPgFAAUIBRAFaAW4BhAGdAaIBowGlAaoBtQG+AcYByQHSAdMB1QHaAecB6gIRAAAAAAAAAgEAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAiM="]
^
Log Method: -[DBGDataSourceConnectionLibViewDebugger _executeLLDBExpression:forRequest:onPotentialThread:iteration:]_block_invoke
Method: -[DBGViewDebugger _initiateInitialRequestWithDataSourceVersion:]_block_invoke
Environment: Xcode 11.4.1 (11E503a) debugging iPhone 8 (Model A1863, A1905, A1906, A1907) iOS 13.3.1 (17D50).
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
I don't know how to fix this?
Thanks for your answers in advance!

Swift unit-testing: Debug info from this module will be unavailable in the debugger

I have Objective-C project and I decided to write unit test in Swift.
Everything runs normally however I cannot see param values during debugging.
When I set cursor on value I see its name and not value:
when I try to print it out in lldb I get following error:
(lldb) po expectedEncryptedStr
warning: Swift error in module AppLibTests.
Debug info from this module will be unavailable in the debugger.
error: in auto-import:
failed to get module 'AppLibTests' from AST context:
I use Version 8.2.1 (8C1002)
Any ideas?
[EDIT]
When I enter with braking point to Objective-C code - everything works as expected

Clunky lldb error while printing variables in XCode's debugger console

Lately I've got problem to print any kind of variable into XCode's debugger console. It doesn't matter which platform I'm building against. I've tried to reinstall whole XCode, command line tools + cleaned/removed the derived data of swift project I'm working on. None of these steps solved my issue, this error prevent me from using XCode for 100%.
Everytime I'm trying to print something I've got this error in debug console.
Printing description of X:
expression produced error: /var/folders/4y/mm1fk7rn5c57ct91syb3ndf40000gn/T/lldb/6651/expr11.swift:1:1:
error: cannot convert value of type 'Int' to expected argument type 'random type'
$__lldb__DumpForDebugger(Swift.UnsafePointer<Swift.Bool>(bitPattern: 0x104c5ced0).memory)
^~~~~~~~~~~~~~~~~~~~~~~~
<EXPR>:18:7: error: cannot convert value of type 'Int' to expected argument type 'random type'
if (1==1) {
where random type can be any type of class/type.
Have anybody came across the same problem lately? Seems like lldb is bit broken when it comes down to print values of swift variables.
I'm using XCode 7.3.1 (7D1014) with latest update of Mac OS X.

Debugging with Swift & Xcode 6.4?

Why po returns these strange errors? (with Xcode 6.4 & Swift)
I try to debug with p / po:
NSDictionary, String and NSNumber all getting similar kind of errors all the time.
For now, I use println() but I am curious what could be the reason?
error: A fatal parse error has occurred. LLDB may become unstable; please restart your debug session as soon as possible.
error: <EXPR>:1:11: error: use of undeclared type '$__lldb_context'
extension $__lldb_context {
^~~~~~~~~~~~~~~
<EXPR>:11:5: error: use of unresolved identifier '$__lldb_injected_self'
$__lldb_injected_self.$__lldb_wrapped_expr_7(
^
For swift language use println() method.For debugging in console you have to keep in mind that you can only get debug info for swift's variables, but can't get it for swift's constants. So change let someVariable to var someVariable.
then in debugger do po someVarible. It will work.
If it doesn't work for arrays & dictionary ,for arrays do something like po print(myArray). Same goes for dictionary.

Resources