Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode debugger not printing variables in some files

Tags:

xcode

ios

swift

I have an issue with the Xcode debugger. Everything works fine in general, I can print variables using po <var> normally... Except in some files, where I can't print anything, and I have a error: Couldn't apply expression side effects : couldn't get the data for variable self error in the console.

Xcode debugger

Weirdly, Xcode shows values correctly on the left debugger panel.

Does anyone have an idea?

Thanks!

like image 377
tdimeco Avatar asked Apr 19 '18 09:04

tdimeco


People also ask

How do I print a variable in Xcode?

If the variable is an image or other type that isn't expressible as text, click the Quick Look button at the upper-right to see a preview of the variable. Click the Print Description button to print a description of the object in the console.

How do you print a variable in Swift?

In Swift, you can print a variable or a constant to the screen using the print() function.

How do I debug in Xcode step by step?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.


1 Answers

Similar observations, all good on the left panel but printing ends with the same message. Quick improvement was to use:

po print(variable)

or

po debugPrint(variable)

Result - prints variable and appends the same error message.

like image 151
Julian Avatar answered Oct 15 '22 20:10

Julian