Xcode 3.2.3 - Debugger shows only _string.h - iphone

In certain locations in my application, if I place a breakpoint and go to that location the code window jumps me to _string.h (which is locked) to this function.
static __inline void *
__inline_memcpy_chk (void *__dest, const void *__src, size_t __len)
When I hit Step I am stuck, and all I see is _string.h. My code still executes and I see my NSLog().
A quick fix is to run in release mode, but in my project I have special code that happens in release. So this isn't really an option.
Does anyone know what is going on?
Thanks.

The problem appears to be caused by my project being a universal build. We created an iPhone version of the build and I can walk through the section of my code where I couldn't before. But then I have the issue of not being able to view my variables.
Oddly enough when I go back to the universal build I don't have the problem in my code, and I can debug normally. Not the greatest fix but at least I can work.

Related

Remote Swift Package: Xcode won't pause at this breakpoint because it has not been resolved [duplicate]

Shortly after updating to Xcode 13.2.1 I started seeing some weird behaviour of breakpoints. When I run an app (in a simulator) some of my breakpoints change their look and turn to dotted blue outlined. Xcode does not stop execution at these breakpoints although code has been compiled, loaded and executed. I checked it in Console by adding some prints.
When I hover over breakpoint Xcode shows a message:
Xcode won't pause at this breakpoint because it has not been resolved
Resolving it requires that:
The line at the breakpoint is compiled.
The compiler generates debug information that is not stripped out (check the Build Settings).
The library for the breakpoint is loaded.
All trivial solutions like reloading, reapplying breakpoints have not helped.
Did anybody else see something like this? Is there a way to solve it?
Screenshot for reference:
Ok, so in my particular case rebooting laptop has helped. All breakpoints are now good. But it would still be nice to know the cause of the problem.
Make sure that the file in which you are adding breakpoint is having correct target set in target membership.
Click on .m file in which you want to add breakpoint.
Select the file inspector.
Check if you have selected correct target for that file or not (check below image).
What worked for me, was to select the files, delete them with - Delete>Move To Trash - and then drag the files back from the trash to the project.
In my case the issue was happening, because class was not added to the target, which I was trying to build.
For my case somehow the code path was never invoked and very likely considered as dead code. The same thing applies when not adding the file to the target that you want to debug.
This can be the case or somehow debugger might not be able to resolve your breakpoint. The first thing in this case should be cleaning derived data and any caches.
But instead of recloning your repo you can just delete breakpoint config from the location described in this answer
In Xcode 14 the problem is much more prevalent and "consistent". I figured out one pattern where it always fails and how to mitigate it.
If you have a final class then breakpoints set on or inside a private method will have that issue. If you remove private from the method or final from the class the breakpoints will get resolved properly.
If tried everything and nothing worked I suggest the following:
Reclone your repo
This is what worked for me.
I just passed through this problem and the solution for me was recreating the files.
Note: The ones I was trying to originally breakpoint on were copied from another project. When I created the new files, even though their Identity and Type looked just the same (target membership, encoding, paths), for some reason breakpoints started to work again.
Note 2: When copying and pasting code to your new files (if done manually), migrated breakpoints - created in the older file - will continue to fail. Only the ones created in this new file will work properly.
Hope it helps.
My case
Working on framework development. Framework is injected into the sample app for development/run purpose. Breakpoints inside the framework won't work.
Fix
Just removing xcframework in sample app and replacing with framework.
Reason
xcframework are precompiled outside of the app, so lib isn't compiled when project is built and that's why breakpoints doesn't work.
For me reboot the Xcode, and it works~

Compiling my App gives no errors but hangs when compiling on device

I've made an iPad App. I was able to run this App on my device and on simulator.
After I've updated several classes (which I tested in simulator) I wasn't able to run my App on my device. It gives no errors but just hangs when compiling.
I'm thinking it's something with a class which came out very large and has some mathematical functions inside (calculations of transforms etc.)
After a long runtime Xcode gives back this error (something about a 'clang error'):
Anyone has any experience with these kind of issues and could find a solution?
EDIT:
Within my viewdidload method i have set 112 float values (i.e. value = 12;) and save them (with NSUSerdefaults).
Only setting these values solved my problem. No idea why this was giving me compile errors. I'm thinking the mathematical functions (after setting the float values) took to much memory or CPU.
Did you try cleaning your build and rebuild again?
Menu > Product > Clean
close & reopen XCode, "Clean All Targets" then rebuild. It should work.
Clean your project, delete the app from you iPad and try again. Should work.
Hope it helps
Are you trying to "Build and Analyze" or an ad-hoc build or debug build?
If your code crashed because of any memory issues or bad access memory due to any infinite loop, try to enable NSZombieEnabled in your executable settings. It will point you to the code snippet where the code crashes.
To enable "NSZombieEnabled", go to
Edit Active Executables -> Arguments -> Variables in the environment -> Add name as "NSZombieEnabled" and value to "YES"
Hopes this helps.

EXEC BAD ACCESS shows no trace/logs even with NSZombiesEnabled set to YES

I'm not exactly sure how to debug this but it seems that I'm getting EXEC BAD ACCESS in the main function of my app. There's no trace or logs of what's going on. I have NSZombiesEnabled but it doesn't seem to be showing anything. How would I debug this?
The first step in debugging is to find out where the crash happens. To do this you need to be able to reproduce the bug.
The Xcode debugger will usually tell you where the crash happened. It doesn't happen in main(), that's simply the entry point for the app and the top of the call stack. You can zoom in to the call stack with the slider at the bottom of the Debugger pane (in Xcode 4).
If the stack trace doesn't include any of your own code, then you may need to set an exception breakpoint in the Breakpoints pane and try again.
If all else fails, you'll have to do some digging:
1) Find a reproducible case where you can make the app crash every time (or almost every time) using the same actions.
2) Since you know what you're doing to make the app crash, you roughly know where in the code you should look. Set breakpoints at strategic places (or use NSLog). After some fishing, you'll find the exact line where the app crashed.
3) Fix the problem. :-)
It may be helpful.
Mainly you are getting this error because you have released something which is useful in furthur.So try to focus on the release.comment the line where you have used the release
Have you tried too clean and rebuild your project, and restart XCode. Latest versions of Xcode sometimes does EXEC BAD ACCESS int the main function with no reasons…
Turns out, pushing multiple view controllers simultaneously will cause this. Hard to debug that!

nslog stopped working in xcode

I have a strange issue and possibly a bug. My NSLog statements have stopped working completely, they do not print even in view did load, application didfinishlaunching etc. The have all turned a brown colour (the same colour as a pragma mark in xcode) and they all have a warning saying 'expression result unused'. Has anyone ever seen this before or know what to do? Am i running in some kind of weird mode? Im running xcode 4.0.2.
Many thanks
Jules
for completeness, I had the same problem and the answer was different, hope it helps someone else who bumps into this post:
I had a framework (an Amazon one) redefining NSLog, went there (Cmd+Click on the Brown NSLog) and commented out the redefinition...
The actual problem was the release_build set to 1. So it wasn't recognizing nslog, as you said it was set for a release build.
I had the same issue :
what worked for me is given below:
Remove the derived data folder
After removing derived data perform the clean action (You can see this option in the product menu)
Quit the Xcode and start it again.
And this did the trick all my NSLog were working fine.
Hoep this helps
Ensure that scheme chosen corresponds to Debug mode because sometimes the pch file might have some definitions such that logging is done only in the debug mode
(Scheme is on to the left of the place where you select iPhone Simulator / iOS Device)
In the view select Debug Area
(There are 3 view buttons, on the top right hand corner of Xcode, press the center button)
Select "Show variables view and the console"
(In the debug area (bottom) there are ther 3 buttons, press the center button)
I had the same issue and the problem was that I was building an Ad Hoc version (schema was for Ad Hoc build). The warnings disappeared when I built for debug.
Try changing the dropdown menu at the bottom of the console to 'All Output'.
if you are using libraries like 'KScan' or 'iKEA' or 'kdc-scan', so it can happens that, they will call methods like this one 'redirectNSLogToDocuments'.
in my case the object of 'iKEA' call the method 'CheckIfDeviceConnected' and this one redirect all nslog outputs to documents. after commenting out, all nslogs works again :)
hope this will be useful for some one.
some steps :-
1) "Clean all targets" or delete your build and rebuild again.
2) If step 1 doesnt work , reinstall xcode

My breakpoint is not working please give me some suggestions as to why not

While debugging the program my breakpoint is not working, so please give me some advice so that it can work properly.
Maybe you've tried to use the breakpoint on unreachable code? Try setting your breakpoint somewhere before the point you want to reach and try stepping from there to see if the point is actually reached.
Possible Reasons could be.
1. After changes in the code you have not built the libraries properly so the breakpoint is not pointing to the right location in the code.
2. If you are putting a breakpoint in a library then make sure the library is build and is built in Debug mode.
3. Clean full environment and rebuild the project.
Open XCode preferences and in the Debugging tab, un-check "Load symbols lazily", this caught me out when I first started iPhone developement. Then again, it might be for any of the other reasons that people have already mentioned.