Why sometimes string values are not available in the Xcode debugger? - iphone

Why sometimes the value of string variables is not available in the debugger when debugging an iPhone app in Xcode?
The mouse over the variable gives:
{(unichar *)Xcode_CFStringSummary($VAR, $ID)}:s
Printing the description to the console gives:
Unable to access variable "myVariable"
This doesn't always happen. Why?

Related

Problems debugging swift project - can't print any variable to the console while paused (exc_bad_access)

For whatever reason my project has started giving me problems printing any variable when I set a breakpoint. Consider the following code:
if let index = hintTypesInUse.index(of: type) {
let indexPath = IndexPath(item: 0, section: index + 1)
hintTypesCollectionView?.reloadItems(at: [indexPath])
hintTypesInUse[type].addHint()
}
If I set a breakpoint on the second line here, and I try to do 'po hintTypesInUse' I just get:
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x1728c634e).
The process has been returned to the state before expression evaluation.
Now hintTypesInUse is accessible in the code itself after this point, and this is just a random example, it goes for anything in this project. The only variables I seem to be able to access while debugging are local variables within that code block.
Tried looking through my build scheme to see if there was anything weird there, but it's set to debug mode, and I compared it with a blank new project and it looks identical to that.
Why can't I access any non-local variables while debugging?
And of course a restart of Xcode and a reboot was all it took to fix the problem. 😆

swift3 how do you use os_log to show the value of a variable in the Console app

When I use os_log("Configure %#", something) I see in the console Configure <private>.
I understand this is the default behavior (at least from what is describe here https://developer.apple.com/documentation/os/logging?language=objc even if it is for ObjC.)
I tried os_log("Configure %{public}s", something) but it just show Configure %{public}s".
Using Swift 3, how do you make the variable something appear in the console ?

po Swift String "unresolved identifier"

I am having trouble debugging Swift Strings
func stringTest() {
let test1:String = "test1";
let test2:NSString = "test2";
// <-- Breakpoint here
println(test1);
println(test2);
}
If I set a breakpoint after these lines and try and print test1 I get the following error:
po test1
error: <REPL>:1:1: error: use of unresolved identifier 'test1'
test1
^
But I am able to print test2 successfully:
po test2
test2
It is a bug of Beta. Xcode6-Beta5 has still this bug.
You can only get debug info for swift's variables, but can't get it for swift's constants.
Temporarily you can change let test1 to var test1 and you will got debug info.
Hope this will be fixed in release version. Good Luck in debugging ;)
EDIT:
Unfortunately, the same issue is still happening in first release of Xcode Version 6.0.1 (6A317)
let test1:String -> debug info is unavailable
var test1:String -> debug info is available
EDIT2:
Yes, confirmed. It is fixed also for iOS apps in the latest Xcode 6.1 under OS X Yosemite.
This is most likely a bug in the debug information output. You can check this by grabbing the PC, for instance from register read pc, and then doing:
(lldb) image lookup -va <PC VALUE>
That will print a bunch of stuff, but the last entries will be all the variables currently visible to the debugger, and where they live (in registers or memory.) If you don't see the variable there, then the debug information must have told lldb that the variable is not currently live.
If you can reproduce this in some example code you can make available, please file a bug with bug reporter.apple.com.

how to know Value of pointer (xcode) without NSLog?

that mean makeUrlforGetBusinessIDLocal is NSString *
I want to know the value of that. without NSLog
how can I know that value? the value is http://isi............
if I do right click and choose edit value, I just can see "0x754cf40"
as we know "0x754cf40" is memory address. I don't want to know it, but the value of that memory address. how can I do that?
Can I do that without NSLog?
You may not be aware that you can type commands into the debugger console to inspect memory locations.
So, if the pointer you want to view is at address 0x754cf40, you would just type:
po [0x754cf40 description]
..into the console. The console is to the right of the variable panel you screen captured above.

UIPrintErrorDomain error 4 while printing on the same printer

I have an application that uses AirPrint and currently, after the first printing I get the following error:
UIPrintErrorDomain error 4
I keep the UIPrinter in a variable that will be used on the next prints(as Apple advice) and when I do a contactPrinter, it actually says that it's available. Even that, it doesn't work.
The only solution is to bring back again the UIPrinterPickerController, choose the printer and then, it will work.
Am I doing something wrong?