Xcode code console printing blank when using po - swift

When I use the terminal/console to print out a value by typing po object it prints blank for all objects. This only happens for my work project which is really big and my small demo projects work fine.
Also its not happening for any of my colleagues. I was using Xcode 10.2 and upgraded to Xcode 10.3 to see if it fixes the problem.
stringValue is an extension on bool that returns "true" or "false" however this happens for all objects so I don't think the code there is relevant.
Due to the huge compile time of our app its quite time consuming to always write print(object) or debugPrint(object) in the code.
Any ideas how to fix the issue?

Can you try to press on i it does the same, but sometimes it's work for me.
Also check this out: XCode's po command has stopped working
Let me know if this help you.

Try the v command.
From the XCode release notes
The LLDB debugger has a new command alias, v, for the “frame variable”
command to print variables in the current stack frame. Because it
bypasses the expression evaluator, v can be a lot faster and should be
preferred over p or po. (40066460)

Related

Swift Xcode 11 breakpoints for conditionals do not work

I am trying to add a Symbolic Breakpoint in XCode to check for UI engine modifications on the background thread.
What I am doing is the following:
However, the error message I am getting back is always:
Stopped due to an error evaluating condition of breakpoint 5.1: "!Thread.isMainThread"
Couldn't parse conditional expression:
error: use of undeclared identifier 'Thread'
UI Engine must be modified on main thread.
I do not understand why the breakpoint condition cannot evaluate my condition. Can someone explain what I may be doing wrong here? I have tried putting that in Obj-c as well, to no luck.
EDIT: Obj-C version, here: !(BOOL)[NSThread isMainThread]
EDIT 2: Xcode version Version 11.3 (11C29)
EDIT 3: Ok, so, closing XCode and reopening has gotten the Obj-C version "working" they pause on a breakpoint for something like, 4-5 minutes each time. This effectively makes these breakpoints unusable. Not sure how to resolve this.
I was able to get your original symbolic breakpoint working as expected by writing the condition as
(BOOL)[NSThread isMainThread] == NO
I suspect there's a better way, and comparing a BOOL directly to NO is very bad style, but at least it got me past the "doesn't work" stage to the "does work" stage.
To clarify, setting symbolic breakpoints and using conditions DOES work, but
I would hazard that self and Thread are not available as symbols for much of the UIKit framework because there is no debugging information available for most of it, hence the error: use of undeclared identifier 'Thread'.
See the answer in this post:
How to log out self when add a symbol breakpoint at -[UIViewController viewWillAppear] method
There is also additional info about creating symbolic breakpoints for child classes and a possible workaround using an objective-c condition here:
Using of symbolic breakpoints for child classes in Xcode?
That being said, if you are only interested in particular classes in your modules where that method (layoutSubviews) is invoked, you can specify the module inside your symbolic breakpoint, and if you have your own implementation of that method (e.g. you have overridden it in your class code), the condition Thread.isMainThread or !Thread.isMainThread will in fact work for that class.
I know this may not in fact solve your dilemma, especially if you need to check all the invocations of layoutSubviews, but I hope it at least helps to explain why a condition using Thread does not work all the time.

Swift Boolean value <invalid>

The attached screen shot says it all: I have a valid true Bool, I negate it with the bang operator, and (Xcode tells me) I have an invalid value.
It appears that this "invalid" value does behave as if it were false. But really, wtf?
I've had this issue in Xcode 8.3.1 and Swift 3.1 https://github.com/onmyway133/notes/issues/278
I tried
Clean build folder and delete derived data folder
Delete the app
Reset simulator
Restart Xcode
Restart Mac
But does not work. The workaround is to
let enabled = disable ? false : true
I'm no LLVM expert but I wouldn't be surprised about this behavior at all, unless optimization is set to Onone in which case it should have left your code alone. The intermediate variable is just asking to be optimized away, after all.
Got the same issue, with correct value for add code like print(theBoolValue).
But when use p in swift command line. Or just check the value in debug stack, the value become <invalid>(Oxfe).

Swift 1.2 -> Swift 2 Conversion time

Has anyone converted an app from 1.2 to Swift 2? My app is small - about 1k LOC, and its been converting for >2 hours now. I'm stuck on the following screen:
How long should I expect this to take? Thanks...
The process is long, but it shouldn't take more than several minutes.
The Swift converter is probably having an issue (e.g.: some kind of infinite loop).
You should abort and try to find what happened or maybe migrate manually.
Swift compiler has an issue with arrays. I have commented out all the elements of the array (like 10x UIColor), left only one element and conversion went smoothly.
Here's how you can debug the issue in your project:
Got to the Report navigator (CMD + 8)
Build your app, select the latest build and watch log (select All Messages filter)
The problematic file will be stuck on the compile status.
Navigate to that file and figure out what can hang the compiler (probably arrays/dictionaries).
Why build not convert? Because it's verbose.

How to evaluate/watch a variable or method whilst debugging in XCode

I come from a Delphi and .Net background and have just started iPhone development. I just came across a problem whilst debugging.
I had the following code:
if ([displayText rangeOfString:#"."].location != NSNotFound) .....etc
I wanted to evaluate this whilst I was debugging but could not work out how to do it. I found the Expressions window and entered the below but nothing happened:
[displayText rangeOfString:#"."].location
As I'm used to Delphi & .Net (and I know XCode is a different product) its very easy to stick in variables, methods etc into a watch window and then see the result but I cannot see how to do this in XCode. Please can you tell me how I evaluate things whilst debugging??
Thanks
In your case, what you would do is at the debugger is type:
p (NSRange)[displayText rangeOfString:#"."]
You can print out the value of objects with po, but things like C structures have to be printed out with "p" and you have to cast the return types from ObjC calls to the correct struct type.
Also, just putting this in the Expressions window should result in a value:
(NSRange)[displayText rangeOfString:#"."]
In both cases you will see the whole NSRange struct, with location and length.
You can watch variables by going in the debugging drop down in the main menu on top and selecting watch variable. You can also right click and you should see the option "watch variable." Alternatively you can hover your mouse over the desired variable while stepping through your code to see its value at that time

Is pl/pgsql debugging broken in PostgreSQL 9.0, or is it just me?

I had the debugger working in pgAdminIII at one point, some time before upgrading to 9.0, but as of right now I can't seem to get it working using the usual steps. I believe it may have something to do with the DLL not loading correctly, because the following query:
LOAD '$libdir/plugins/plugin_debugger.dll';
show shared_preload_libraries;
...returns a blank row. The DLL is present, and if I change the load string, it complains, so I'm pretty sure it's finding the DLL okay, but not successfully loading it. show local_preload_libraries returns the same thing.
Any ideas?
It's just me. I had been carelessly selecting non-plpgsql functions the whole time. Of course, the aptly-named debugger does not operate on SQL or plperl functions...
Boy is my face red.[/dilbertquote]