Tuesday, February 14, 2012

Program received a signal "SIGABRT"

This article is moving away from Qt SDK, but it is still on the track with idea of development for mobile devices. You will encounter the error
Program received a signal "SIGABRT"
from the title of this article if you are playing with Xcode and you are trying to develop for iOS. If you ever received such an error you will notice that it escalates to the main.m file that most of the time you as an developer didn't even touched. There is no universal answer on how to solve error causing this but I am about to share with you a trick I learned recently that will help you find out what is causing this error. Hit read more to read the entire article.
In the Navigator pane click on Breakpoint. This will show you list of all the breakpoints in your project. Probably you don't have any. At the bottom left you will notice the + icon. Use it to create a new breakpoint. You will be asked what kind of breakpoint you want to create. Choose Add Exception Breakpoint... Choose to create Exception breakpoint on all the exceptions and right when they are thrown.
Now run the code again. The code will still crash but it won't escalate all the way up to the main.m file. It will show you the line of code that triggered the crash. This way it will be much easier to fix it.

I have learned this neat trick from Debugger video created by Standford university's  iPad and iPhone Application Development video lectures from iTunesU. So if you didn't understand what I described here be sure to watch the video. The problem I am talking about here is covered 2minutes and 22seconds after the start of the video.
I encourage you to watch the whole video because it is very useful with lots of tips and tricks.

You have to have iTunes installed in order to watch this video but if you have a problem like this one you probably already have it.

This is done using Xcode 4 and iOS 5 but i think it could be done in previous versions too.

2 comments:

  1. I started doing iOS development in late 2010, and also watched that debugging session video two weeks ago and just thought: ok - always set an exception breakpoint - that would have saved me weeks of frustration - why didn't I learn decent software development somewhere in the first place. Like at Stanford.

    ReplyDelete
  2. I was following a book I considered good one and they didn't explain this. Every time I would made a mistake in code it was impossible to figure out what I did wrong :) I was so happy when I found that video that I decided to write this article and share. Hope it helped someone as much as it helped me :)

    ReplyDelete