Xcode throws an exception in Main() in iOS 8 with 'all exceptions' breakpoint Xcode throws an exception in Main() in iOS 8 with 'all exceptions' breakpoint objective-c objective-c

Xcode throws an exception in Main() in iOS 8 with 'all exceptions' breakpoint


As stated in the comments, you should turn off catching the C++ exceptions by editing your All Exceptions breakpoint.

In order to do that, right click on your breakpoint and change Exception from All to Objective-C:

change All to Objective-C

Exceptions in C++ code are part of normal app functionality. However, exception breakpoint is not catching unhandled but every raised exceptions, even when they're handled correctly later on, hence the stop in execution.


TLDR; In my case the cause of problem was missing fonts.

I also had this problem. While @Johnnywho is correct that leaving Exception Breakpoint for Objective-C only, stops the unwanted behaviour, it still does not explain what is the real cause, why does it run without exception on iOS7 and why does this happen only on some projects.

That's why I went on and dissected one of my projects in which I had this problem, until the point where I was able I found the cause. I suppose that there could be more than one cause for this behaviour, but in my case that was missing custom fonts.

Quick way to test it:

  1. Start a new single view project

  2. Enable breakpoint on all exceptions, including C++ (Breakpoints / + / Add Exception Breakpoint)

  3. Drag into the project some custom font (allow copying and check the target to add it to)

  4. Add a label to the view in the main view controller

  5. Choose the custom font for your label (on Xcode 6+ it should show in the font picker as soon as you drag it into the project).

  6. Run the app and confirm that you see the label in your custom font (it seems that we don't need to add the font file name in Info.plist for the key "Fonts provided by application" anymore, if the custom font has been used in a storyboard of xib of the app).

  7. Now remove the custom font from your project (either by unticking target relationship or by removing it in target settings / Build Phases / Copy Bundle Resources)

  8. Delete the app from your device or sim (to delete the font file from the app bundle)

  9. Product / Clean

  10. Run the app again (now the label still has the reference to the custom font but the app does not have the file for it). You should notice the mysterious exception if you run on iOS8.

  11. Run the app on device with iOS7 or sim with iOS7 (you'll need to change the iOS Deployment Target to iOS7 for that). Although the label won't show the custom font, there won't be an exception.

  12. Add the font file back to the target and the breakpoint does not stop on run anymore.

So my conclusion is that on iOS8 the missing fonts cause C++ exception while on iOS7 they don't, hence the breakpoint trigger.

Similar exception (and breakpoint trigger) can also be caused by incorrectly written font file name in Info.plist file under the key "Fonts provided by application".


Just summarized previous answers which helped me to fix it.

Problem: When you add custom font and then apparently delete (replace) it, somewhere in project is still his reference and the breakpoint stops several times at main C++ lib breakpoint stops in iOS 8.

Solutions

1) Find in project and delete (replace) all references to those fonts. Might in some nibs, submodules, etc…

2) If you can’t fix everywhere (e. x. read-only libs use them) or problem still exists after solution 1 , add those old fonts back to project

3) Ignore it - It is C++ lib so change breakpoint exception from “All" to "Objective-C" only