Xcode 4, debugging, breakpoints, NSLogs - iphone

I am hoping someone can help me. I have just started running xcode 4.01 and for some reason whenever I run an app, it does not stop on breakpoints or display the NSlog messages. I have a message in my viewDidLoad and it never shows. I even breakpoint on this log and the best I can get in the output window is:
pending breakpoint 1 - "universalTestAppDelegate_iPad.m:15" resolved
pending breakpoint 2 - "universalTestAppDelegate_iPhone.m:16" resolved
Actual code is:
-(void) viewDidload
{
NSLog("in viewDidLoad");
}
So it appears it sees the breakpoint but never stops on it. As I said, brand new to xcode 4 so any idea on what I am doing wrong? Uninstalled and reinstalled and still nothing. Also, if it means anything, in the Scheme to choose where to run, I can select IOS devie, iPad 43 simulator and iPhone 4.3 simulator. Tried both and still nothing. Why can't I select/see other versions of the IOS?
BTW: The above is because I do not have my iPad or iPhone connected. Thanks in advance for any and all help.
Geo...

Your method is just never called.
Make it
-(void) viewDidLoad
with big "L" and your chances of "breaking" will sky rocket. ;)

Two possibilities:
You don't have breakpoints turned on. Use the Product->Debug->Activate Breakpoints command to rectify this.
You have breakpoints turned on but you placed your breakpoints on lines that haven't been executed. If your log statement doesn't appear in the console, that would indicate that the method containing that statement isn't executing, so it's no surprise that the breakpoint on that line has no effect.

I had similar issue where the debugger would not stop on breakpoints in the simulator using Xcode 4C199. Turns out the simulator was just buggered and restarting it resolved the issue.
I also had the issue with XCode 3 where I had localized the name of the app to a set of Japanese characters. The debugger didn't like that. I solved that one by having english name for debug configuration and japanese name for release.

Related

Some breakpoints not hit Eclipse ADT

I have 4 breakpoints but only 2 are getting hit. What I notice is that the breakpoints getting get hit show a small check mark in the breakpoints view.
What does this check mark mean and how can I activate my other breakpoints?
There is some explanation of the various symbols here:
What different breakpoint icons mean in Eclipse?
I've just tried it myself and it appears that your breakpoints are not disabled, but the little check mark only appears once you're actually executing the function that the breakpoint is in. So the reason your breakpoints aren't hit, is because there is no code path that leads into the code you're trying to debug, i.e. you're not calling it.
Found it. This is an issue where breakpoints other than on the main thread are not hit. This is an exclusive problem on the Samsung Galaxy S5 under Lollipop.
http://developer.samsung.com/forum/thread/android-studio-does-not-stop-on-some-breakpoints-when-connected-to-samsung-galaxy-s5-with-lollipop-5/202/277622?boardName=General&listLines=15&startId=zzzzz~

App opens then immediately closes - iphone simulator

When I "run" my app from XCode the simulator comes up and the app attempts to run, it animates to a black screen for a second and then the app closes immediately.
The app was running fine before and now suddenly won't work.
There is no output on the console, no errors or anything and the app isn't crashing (as far as I can tell).
I have tried deleting all my user specific files in the xcodeproj package, but this hasn't changed anything.
Is there any other reason why this would happen? How do I fix this?
Thank you.
ADDITION: NSLog(#"something"); in the application:didFinishLaunchingWithOptions method doesn't show up on the console.
A reboot of my Mac seems to have fixed it. Thanks guys for your help. :)
if you are using a new Xcode(4+) and previously 3, there may be issue. Try setting the Architectures (Target -> Build Settings -> Architectures) to support armv6 too, presently it supports armv7(standard) only. If my memory is not deceiving me I guess I had such an issue.

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

Debuging to simulator crashes with "exited with status 5" unless I have breakpoint

For some reason the app I am working on has very bad PMT! Literally! Most of the time I cannot debug using the simulator without putting a breakpoint in my AppDelegate. If I don't it exists with "status 5". If I put a break point in and simple continue it works perfectly well, it also works if I run the app in the simulator when not connected to the GDB.
I have tried the source on a second machine with exactly the same results. I dont have this issue building to the device?!?!?!
Thanks
from : http://forums.pragprog.com/forums/100/topics/2168
Sep 14, 2010 9:55am
Mark Allen
(1 post)
I had this too. Fortunately I had the project under source control, so I did
a diff and realised the project file is not the culprit. Turns out there is no
need to create new projects or anything. Just delete your personal settings files
for the project. They will be username.mode1v3 and username.pbxuser. I didn’t
figure out which file was the cause, but deleting them sorted it out.
I had same problem. Restarting X-Code didn't help.
What did help was clearing all my breakpoints.
From the X-Code menu, click Run -> Show -> Breakpoints, then, from the breakpoints screen delete all breakpoints. Shut down the simulator, then rebuild the project.
Problem solved for me.