How to know why application crashes in simulator - iphone

I'm running my application on the simulator but as soon as it starts it just closes I guess it crashes, however I dont get any error message or reason why it's crashing, I'm running it as debug also, is there anyplace or anyway to get an error message?

Try switching to "debugger" view, and look at the console from gdb, if it crashes you will see the error, and hopefuly the call stack.
Example of crash message: EXC_BAD_ACCESS.
If you don't have the call stack visible, you can try to type 'bt' (for back trace) at the gdb prompt.

A lot of times when my application randomly crashes before launching, there is a problem in an interface builder file (such as a connection to a now non-existant object). Check your interface builder files to see any potential bad connections or errors and if you can't find any, put an NSLog in your applicationDidFinishLaunching method to see if the application is actually being started before it crashes.

In Xcode, choose Run menu, then choose Debug — Breakpoints On. Xcode should now point you to the location in code where your app crashes in the Debugger view.

Related

debugging crash errors on app launch

I am getting the following crash when I run the app on my device, but it works fine on the simulator:
Any idea of where I should probably start looking? This is super abstract to me
Also it seems that every time I run the app, I am getting a different error.
Here's a bigger image link
It might be because of zombie. Put the exception breakpoint in xcode and analyse.
In case if you don't know how to put exception breakpoint follow below steps:
Press cmd + 6 to open breakpoint navigator
Tap on "+" put present at the bottom left of the screen and select "Add Exception Breakpoint..."
Press Done.
Now run the program.
The program stops at the point where the exception is thrown. Analyse the problem and fix it.

Getting crash location in iOS

I am getting a crash in my application which I am not able to trace out. In the log I am getting :
[CFString release]: message sent to deallocated instance 0xeb8a560
Even on debugging I could not trace out the crash. I placed breakpoints and enabled NSZombie but still not helpful. Does anyone have some idea for getting the location of crash?
for getting the exact location of crash, you need to add 'Exception BreakPoint' , that will add breakpoint to exact location where the crash occurs.
In the left side column of xcode 4:
tap on the breakpoint tab (the 6th tab over)
tap on the + button in the bottom left of the window
tap 'add exception breakpoint'
tap 'done' on the popup
reference "Run > Stop on Objective-C exception" in Xcode 4?
A string object over released. You can create an exception break point to find where it crashes. Also you can try using bt in GDB to get crash log.
This link lots of tricks and tips.
This type of error (using class retain/release memory management) can also be debugged using the Zombies Instrument. Often (not always) you can see the history of where the deallocated object was retained/released and figure out why is vanished out from under you.

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!

iPhone app fatal error

Ok, I only made a minor change to a project of mine in Xcode (I just added a new .h, .m, and .xib file, they're very small), and now it won't run and gives me this message:
"fatal error: error writing to -: Broken pipe"
WTF? So I removed all the changes and tried to run it again and it STILL gives me the error, what's the deal?
Restart Xcode. If it still throws the error, disconnect your iOS device, reboot it, attach it again.
Sometimes I get this error when I press run while my app is still working on the iphone. This may persist even if you restart xcode or your computer. What works for me is to hard restart the iphone. keep pressing powerbutton on iphone for 10 seconds untill it goes out and then press again, the error should go away.

How to figure out what caused runtime error on IPhone App?

In Xcode, say you write an app for the iphone and it has a runtime
error in it. What I've been seeing is that it just closes out the
program in the simulator but doesn't really hilight or give me any
feedback as to what line caused the crash... am I missing something??
Note: I don't consider the console to be very effective since
it just spits out an error, but I still need to find where in
the heck that bug is stemming from in the code.
In the console, above the stack trace, it should say something like "[ClassName selectorName] unrecognized selector sent to instance".
Make sure you really meant to send that selector to that class. If you post what it is, we might be able to help more.
To access GDB, enable breakpoints, add one to your code by clicking in the line number gutter, press build and debug and finally open the debugger (CMD+Shift+Y).
Look in the console (command-shift-R).
You can set a global breakpoint on exceptions, which will let you trace the exact point at which they occurred. To do so, select the Run | Show | Breakpoints menu item in Xcode to bring up the breakpoints dialog. Select Global Breakpoints (so that this will be enabled for all of your projects) and create a breakpoint on objc_exception_throw in libobjc.A.dylib.
Now if you start your application by choosing Run | Debug - Breakpoints On, or manually enable breakpoints in the debugger window (Run | Debugger) before running, the application should halt at the point where the exception is thrown. You can then look at the stack trace in the debugger window, where it will highlight the particular line that caused the exception.