iOS app exception on app start (doesn't crash the app) [duplicate] - ios

I am using Xcode 6 (GM, I didn't download betas), and I am developing apps for iOS 7+. For all my projects, I just opened the same projects I used to work on in Xcode 5.
In the Breakpoint navigator, I have the All Exceptions breakpoint on. It is set to Break: On Throw. Now, each time I run my app (whether on a device or in simulator), it stops execution on the line return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); in the main() function.
If I press Play to continue program execution twice, the program runs fine. So this doesn't prevent me from working, but it is annoying to have to manually play the execution each time and reset my editors.
I like the behaviors I have set up in Xcode (taking the current editor to where the execution has paused), and having that All Exceptions breakpoint is important IMO. (So I don't want to change those)
By running the same code, with the same environnements, for an iOS 7 target (again, device or simulator), the exception is not thrown.
Any clue what could cause this strange behavior?

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:
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:
Start a new single view project
Enable breakpoint on all exceptions, including C++ (Breakpoints / + / Add Exception Breakpoint)
Drag into the project some custom font (allow copying and check the target to add it to)
Add a label to the view in the main view controller
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).
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).
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)
Delete the app from your device or sim (to delete the font file from the app bundle)
Product / Clean
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.
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.
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

Xcode 9, sometimes there are exceptions that are thrown but iOS is catching it gracefully. This will help
source
for my case, it was a user-defined attribute in nib

I had a same issue, the issue was i have added some interface files from other project which has different font in it. Just find them and remove.

Related

Xcode crash on opening storyboard

I am developing an app for iOS with Xamarin. Lately, I haven't been able to access my storyboard file in Xcode or compile my app anymore because Xcode crashes right away when opening the .storyboard file.
The error message is the following:
ASSERTION FAILURE <br>
Details: Creating an out of band arbitration unit with a view (<IBUITableViewCell: 0x7fa88d13a5d0>) as the root under another view (<IBUITableView: 0x7fa88cf000e0>) is not yet implemented.<br>The view would need to be in two arbitration units, the one above for positioning constraints, and the root of the one below for sizing constraints. <br>But then that means that subviews cannot have constraints that affect the size of the view, so the view must have ibExternalTranslatesAutoresizingMaskIntoConstraints set to YES.
<br>Object: <IBUITableViewCell: 0x7fa88d13a5d0>
<br>Method: -ibArbitrationUnitWasCreatedWithReceiverAsRootUnderParent:
I tried rebasing my storyboard to the last version that worked (the one the app was submitted to the app store) and weirdly, even that version didn't work.
My plan was to manually remove and every view controller and add them one by one to figure out where the error is.
However I don't understand why XCode crashes when opening the storyboard and not just shows me exactly where the error in my xml is.
So if anyone has encountered this problem before and has a better way to fix it than to manually do it, I would really appreciate any help.
ibExternalTranslatesAutoresizingMaskIntoConstraints needs to be YES
Sounds like the Storyboard was created with an older Xamarin.iOS that introduce this issue.
The fastest solution is to open the storyboard in vi (or Xcode / View As Source, or another text editor of your choice, and replace all translatesAutoresizingMaskIntoConstraints="NO" with "".
Save the file, re-open it in the Storyboard editor and fix your contraints.

iOS TodayView Widget breakpoints not working

I'm working through this tutorial and it works just fine on a simulator, except I don't understand how the methods are being called. The today view widget displays fine but when I add breakpoints to the methods (e.g. ViewDidLoad, widgetPerformUpdateWithCompletionHandler) the breakpoints never seem to be called.
I'm trying to figure this out as I've added extra code - e.g. NSLog to display some values within the methods but do not see any output from the NSLog calls.
Can someone explain why the breakpoints are not working? I'm guessing that it has something to do with the extension methods are executing in the 'background' but am not sure.
Thanks
You are able to have the breakpoints you set in your today extension activate by following the procedure below:
1) Set breakpoint in your extension code (viewDidLoad is a good option to test)
2) Launch your app as you normally would by selecting your app's target and hitting run.
3) Make sure that your extension is installed in the today view (open the today view and hit the edit button to add it if it is not)
4) Close the today view.
5) In Xcode select your today extension target and press the run button. You will be prompted to choose an app to run. Select "Today".
6) You should see the today window appear on the simulator (this also works on the device). Your breakpoint will be hit.
NOTE: You may hit an exception breakpoint in your app prior to the today extension launching because your app is sent to the background. If this happens just skip over the breakpoint and you will hit the breakpoint in your extension as expected. This procedure also allows you to see console statements from your extension.
I'm not sure if this is related to your specific situation, but in an app where I have 3 extensions, I noticed that breakpoints don't work in 2 of them.
I noticed however, that the breakpoints start working if I run (from XCode) the extension on which the breakpoints work, and access one of the other extensions (from inside Photos app in my case). For some reason, running the other extensions from XCode would not trigger the breakpoints.

Break on main function but not crash [duplicate]

I am using Xcode 6 (GM, I didn't download betas), and I am developing apps for iOS 7+. For all my projects, I just opened the same projects I used to work on in Xcode 5.
In the Breakpoint navigator, I have the All Exceptions breakpoint on. It is set to Break: On Throw. Now, each time I run my app (whether on a device or in simulator), it stops execution on the line return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); in the main() function.
If I press Play to continue program execution twice, the program runs fine. So this doesn't prevent me from working, but it is annoying to have to manually play the execution each time and reset my editors.
I like the behaviors I have set up in Xcode (taking the current editor to where the execution has paused), and having that All Exceptions breakpoint is important IMO. (So I don't want to change those)
By running the same code, with the same environnements, for an iOS 7 target (again, device or simulator), the exception is not thrown.
Any clue what could cause this strange behavior?
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:
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:
Start a new single view project
Enable breakpoint on all exceptions, including C++ (Breakpoints / + / Add Exception Breakpoint)
Drag into the project some custom font (allow copying and check the target to add it to)
Add a label to the view in the main view controller
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).
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).
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)
Delete the app from your device or sim (to delete the font file from the app bundle)
Product / Clean
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.
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.
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
Xcode 9, sometimes there are exceptions that are thrown but iOS is catching it gracefully. This will help
source
for my case, it was a user-defined attribute in nib
I had a same issue, the issue was i have added some interface files from other project which has different font in it. Just find them and remove.

Strange "Crash" with Font added to Info.plist

I've added a custom font TTF file to an app I'm making.
I've also added the UIAppFonts key to the plist, as required.
Now, when I launch the app, it hits the "app is crashing in AppDelegate" breakpoint we all know so well.
I can't figure out a way to inspect the exception, but what's stranger is that if I play it through, the app continues just fine -- even allows me to debug. On top of that, the font in question is actually loaded, so there doesn't seem to be any issue there either. Not sure where to start looking for this one.
The font file is probably not added to the target.
Please remove the white spaces from the font file name. And change name in info.plist file.
And Use the same font name which in in the .ttf file. For more information you can check NSGOD's Answer here
Do you have a symbolic breakpoint set for "objc_exception_throw"? It will break on all exceptions, including the ones that will be caught by some code's try/catch frame.
Since you are seeing it show the break at UIApplicationMain, it is likely this is the closest source code to the problem. Check the stack frames in the left column to see if there are Apple internal methods being called.
Change the slider at the bottom of the left column in Xcode to show more of the stack frames if some are hidden.

App pausing but not getting an error after running a clean

I have no idea what is after going wrong but I'll state the events that happened before the error occurred
1: App was running fine as I was adding functionality.
2: I noticed that one of the view controllers was not showing the correct version but an older one. (I had added in a segmented control and it wasn't showing up)
3: I tried to uninstall the from my phone and build it again but it was still showing the old controller
4: I tried cleaning the project to recompile everything, after this step the application started to give me this problem
http://i.imgur.com/105yDr8.png
Some extra information:
1: This error occurs on the black screen before any view controllers load
2: The view controller I was working on was not the first view controller (so I do not think that it is the problem)
3: The main view controller has not been changed in days and was working perfectly since it was finished
I have absolutely no idea what is going wrong, and help would be greatly appreciated
UPDATE 1
New error message
http://i.imgur.com/5XVJWHT.png
UPDATE 2
Screenshot of storyboard and a finder window that opened when I clicked "show in finder on the storyboard". This would lead me to believe that it does know where the file is
http://i.imgur.com/Ybas1Yx.png
You've (probably accidentally) set a breakpoint at the return UIApp...-line.
You can identify a breakpoint by it's blue color at the left of a line. If it's activated, it's dark blue, else it's light blue. You can just drag it either to the trash can or somewhere else in your window to completely delete the breakpoint.
your app is getting crashed due to exception check the pannel objc_exception_throw
add exception breakpoint and you'll get the line of code where your app is crashing
It sounds like something is broken, and throws an exception. You're just seeing the exception being caught.
The way to investigate what is throwing is to add an exception breakpoint. Go to the breakpoints list and hit +, choose exception breakpoint and leave it at all. This should give you a breakpoing at the point where the except is being thrown.
As to what is happening. You had an app that ran with an old VC, you deleted the app and re-installed and now it crashes, so best guess is that your old version had the VC, but new one doesn't. Sounds like a missing xib or storyboard. It clearly isn't missing from the project, as you'd see that immediately, but check for target membership, changed name or localization problems.
I fixed the problem by renaming the storyboard to MainStoryboard1 and changing the target in
project > target > summary > iphone/ipod deployment

Resources