'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN' exception - ios

My app throws the following exception error after I press a UIButton which changes from a 'play' image to a 'pause' image. It doesn't always happen immediately, sometimes it happens when I pop to my root viewcontroller.
Note: It only happens in iOS 9.x, while in iOS 10.x works perfectly

After hours of experimenting and searching, I discovered that the error was produced, because I was using vector pdf images in my project for that specific UIButton. As soon as I replaced them with their equivalent png files, the exception stopped occurring.
(Note: if someone finds out why this happens please post it)

Related

Swift Programming issues: Exceptions causing my app to crash AND auto-layout localization issues

I am writing my first app using Swift. It's a simple music player that's designed to randomly play songs from different genres on my iPhone. I built the UI and the code according the specifications of a YouTube tutorial I watched (https://youtu.be/aiXvvL1wNUc), but my app crashes when I try to run it, either in simulator or on my phone. I keep getting two messages.
First is a warning on the storyboard about how fixed width constraints may cause auto clipping (width is set at 120).
The second issue I'm running into also happens when I try to run the simulator.
I get an exception issue that says
reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-BYZ-38-t0r" from storyboard "Main", but didn't get a UITableView.'
I'm including a screenshot of this error as well.
Any help here would be awesome. If anyone would like a closer look, I also saved the entire code to a Dropbox, so just let me know. Thank you.

App crashes when I click on side bar menu

Before it worked, when I made the update iOS 13 and updated xCode to 11, I am not able to use the side bar. The application is using the pod SideMenuController and when I click on the icon of side menu to show it, it crashes and shows me this message:
Assertion failure in -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3899.22.15/UIApplication.m:5311
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'
I will answer why didn't I show the code, because I didn't made it, the engineer that was before me made it with a pod named SideMenuController. So I'm not familiar with the project or the code inside. I did a lot of research and I fixed it and I wanted to share the solution with you. ( PS: I don't know how it worked ) in the description of the pod, I needed to comment this line:
SideMenuController.preferences.animating.transitionAnimator = FadeAnimator.self
and another line to change from :
SideMenuController.preferences.animating.statusBarBehaviour = .horizontalPan
To this line :
SideMenuController.preferences.animating.statusBarBehaviour = .showUnderlay
And it worked like magic, Thank you guys

On iOS 11, Sticker Pack extension crashes on first launch

The first time I run my Sticker Pack extension on a simulator, I get the following crash:
2017-10-25 14:56:10.513268-0700 MobileSMS[94610:5136614] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘attempt to scroll to invalid index path: <NSIndexPath: 0x60c00023b820> {length = 2, path = 0 - 9223372036854775807}’
I didn't see an answer for this on StackOverflow, so I'm posting this question and will answer it below. Let me know if this is incorrect!
The simulator is actually trying to scroll to the sticker pack app icon and press it. For some reason, the simulator doesn't automatically enable your sticker pack, so there isn't an icon to press.
To enable your sticker pack:
On simulator, open message thread.
Tap the ellipsis (three dot) button at bottom.
Tap edit at top-right, then enable your app.
Re-run your app and it will work! I wrote a blog post about this fix. The post is essentially the same content I've posted here.

iOS: Scrolling TableView leads to NSException without details

I have a tableview and get the error
libc++abi.dylib: terminating with uncaught exception of type NSException
if I start scrolling the table. If I jump to other table position with help of the section indices on the right there is no problem. Only the scrolling causes the crash.
What is really weired is that I do not get any further infos. Non of the threads points to my code and I tried it with XCode 8 and XCode 8.1 beta 2.
Usually XCode tells me what the problem is. Also I made sure that all indices are in its bounds, etc.
Any idea how to debug this?

drawWithRect crashing with an exception breakpoint on iOS 8 (Does not crash without exception breakpoint)

Happy iPhone Day everyone! I hope everyone managed to get their hands on one.
I have a strange issue. In my code, I have a UITableView and if the user selects the Email icon in the UINavigationBar, it does two things:
1) Opens up the MFMailComposer
2) Creates a PDF in the background of the contents of the UITableView and attaches it to the email
This has so far been working very well in iOS 7. With iOS 8, if I set an exception breakpoint in my code and run it on an iOS 8 device, it will crash when I click the email icon (iPhone 5s), pointing to the code below:
[strheader drawWithRect:CGRectMake(65, -670, 1024, 100) options:NSStringDrawingUsesLineFragmentOrigin attributes:#{NSFontAttributeName:headerFont} context:nil];
It doesn't let me jump in or out of this breakpoint or do anything to find out what's going on. If I remove the Exception breakpoint, there's no crash. If I run the app on my device and disconnect the device from Xcode, run it again, there's no crash.
So ultimately, there's no crash when running my app, but it makes me extremely nervous that with an exception breakpoint, it crashes at that code above which means something isn't right somewhere.
There are no warnings in my code. The method that does the saving of the PDF to the email (which contains that code) is extremely long; if it's required, I'll paste it here but I don't want to make this question longer than it needs to be.
If I remove the exception breakpoint from that line and just set a regular breakpoint, as expected, it stops at that point. I run through and there are no errors at all. If I run through the whole breakpoint, it does what it needs to and then shows the MFMailComposer in the App. So it's not actually "crashing", but the exception breakpoint clearly has a problem with it.
How can I find out WHY it's crashing? More importantly, how can I fix it? (which will probably only be answerable after the first question gets answered).

Resources