Why am I unable to view values in debug area? - ios

After adding an expression -in the debug area-:
I am facing an issue, which is: when reaching the desired line (via a breakpoint), the value is always appears as "Invalid expression", with a message logged to the console:
Shared Swift state for (My Project Name) has developed fatal errors
and is being discarded.
REPL definitions and persistent names/types will be lost.
To double check that the variable has a value (also as a workaround to see what is the actual value of the variable), I tried to log it via dump() and it seems that it does has a value.
Although there is a workaround -as I mentioned, by using dump()-, I wonder what is the reason of causing this issue?
I am not pretty sure if it could be a bug in the Xcode; I am using Xcode version 8.3.2.
Remark: If you have no idea what is adding an expression into the debug area, you might want to check this Q&A.

Related

Unable to Build mac project in XCode14.0/14.1 with macOS ventura

I have recently updated to macOS 13.0 and for that minimum XCode Version required is 14.x series. But my existing project never getting successfully building. Its getting stuck at some point.
Its not getting failed. Build process screenshot is attached below. Its not pointing to any specific class. Seems like there are lots of classes which are getting compiled successfully at last but still build process is stuck at some point:
Seen similar threads like below on apple pages but nothing seems working. Does anyone got resolution?
Xcode 14 project compile error
XCode 14 compile errors immediately disappear or do not appear at all
Something similar has happened to me in the past on a number of occasions. If the Swift compiler is hanging mid-build, usually the issue is that there is some expression that is too complex for Swift to do the type inference on.
What you need to do is first find the exact statement that is causing the hang. This is how I do it:
First find out which source file is causing the problem. Look at the build log to figure this out (the build log can be located by looking at the reports navigator ⌘9 ). Find the build log and click on it. The build log will appear in an editor window.
One of the compiles will still be in progress and its file is the one you want.
The next thing to do is comment out all the code and recompile. This time the compilation will finish (if you have the right file, or there is only one) but probably with a lot of errors. Then you add the code back in, function by function, until one of them causes the compilation to hang again. If it's not obvious which line of the function is causing the problem, comment it out again and then add the lines back one by one until the compilation breaks again.
Once you have located the line, you need to simplify the type inference on that line. If it's a closure, try adding an explicit declaration for its parameters and return type. If it involves some complex array, try adding a type annotation to its declaration. Also try breaking down complex expressions into multiple simpler expressions.
There's no one size fits all answer to this but usually, once you have located the exact line that is causing the problem, it should be reasonably obvious how to fix it.

Xcode 8 debugger doesn't print objects and showing expression produced error

I have upgraded Xcode 8 but when I'm debugging, every object showing following error :
expression produced error: error: Couldn't materialize: couldn't get the value of __once: extracting data from value failed
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
This seems system level error, so I've already tried all possible solutions but still doest work.
I don't know of any bug that would cause this to happen for all types. Except, if this is a Swift project, make sure that you have cleaned and rebuilt all the swift code you depend on from source. At present, Swift really needs the whole world to be built consistently for debugging to work. If that doesn't help, then we will need more details to figure out what is going wrong.
Might be worthwhile to file a bug with http://bugreporter.apple.com since that makes gathering the data needed to solve the problem easier.

How to get Xcode debugger to show 'self' and variable values again?

For some reason, Xcode has stopped showing the value of 'self' when debugging (it just says 'self' and nothing else. Local variables are showing, though. Also if I add valid values with Add Expression, they always say Invalid Expression.
It used to work well until a while ago, although I can't determine when it last worked. The debugger seems to work well for other projects, so I'm guessing it's something in the project settings.
I've inspected build settings, and made sure that optimization values are set to None [-Oo] for debug (and None [-Onone] in Swift).
I've also made sure that the current scheme is Debug, and that Debug Scheme has 'Debug executable' selected.
This is a Swift project, with some Objective-C files, and it's in Xcode 6.4 (6E35b).
How can I get Xcode to show the value of 'self' again, and to display values of expressions that I add in the debugger?
Finally solved this.
#AustinT and anyone who runs into this:
The problem for me was caused by a double installation of crashlytics, through cocoapods and through traditional installation.
I tried to leave only the cocoapods version for hours, following the official guide, but I couldn't get it to work. I got a 'not found' message on the build phase script.
So eventually I gave up and just left the traditional installation version, and erased every mention of the pod version in the project.
The debugger went back to normal, and life is good again.

Unity3d: Error building Player: Append is not supported

I receive this error when appending an already-successful build in XCode. What I don't understand is I'm not changing anything when appending, and this error shows up.
I've never used an 'old version of Xcode' as the error implicitly states.
Does anyone know how to get append working on a consistent basis?
This is a very simple project, and I'm using Playhaven and TapForTap SDK's, if that offers any insight.
Turns out, XCode upgraded itself without telling me. :(
I rolled back to the version I was using and all is well.
With no code snippets or error logs, it's very hard to determine what the source of your problem is. There's no way to know if your error is describing the cause of your problem or a symptom of the problem without more information.
I can only offer some suggestions:
My first thought is that you're using a deprecated method in your code somewhere, possibly "Append", which if that is the case, more than likely has an updated counterpart, but you'll have to check documentation regarding that.
If you've used "Append" previously with no errors, then you should look into what exactly you've changed in your new build, and verify that the methods you're using are supported.
If your errors are vague or unhelpful, you can begin the process of elimination and start commenting out blocks of code until it builds successfully, and narrow down the source of the problem significantly.
However, it would be to your benefit to expand your question with more information.

SIGABRT Xcode 4.2 issue

Since I've upgraded from xcode 3.1 to xcode 4.2, when I debug a program and for some reason I get a SIGABRT error (i.e. calling a method of an object that doesn't exist) Xcode shows the error in the main function of the program, instead of the line that is generating the SIGABRT.
Maybe I'm missing some kind of configuration in the debugger or in xcode? any ideas?
I had the same problem for a long time and I found a solution just now. Don't know if it's the most kosher way, but at least it works for me. Basically you should create a global breakpoint (global meaning applying to all your projects).
Check out this blog post, and this tutorial on how to create symbolic breakpoints. I myself created an Exception breakpoint (it catches objc_exception_throw too) this way:
and then moved it to "User" breakpoints space:
Make sure that the scheme you are using has breakpoints active. You can turn them on by hitting the button next to the scheme selector.
http://bit.ly/zuTnpF
What did it for me, was something that I found here that has to do with creating NSZombies
I'll at least copy the highlights:
Go to your project in Xcode 4
Environment variables can be set up in the Scheme editor (find Product -> Edit scheme… in menu bar):
Name the variable as NSZombieEnabled and set its value to YES.
Run your app in Debug mode. You likely get a … message sent
to deallocated instance… message and the debugger stops at the line in error. This information leads to the problem.
When ready, disable NSZombieEnabled by changing YES to NO.

Resources