UINib initWithNibName crash before app load - ios

I have an iOS app that runs fine on the simulator, but crashes on all devices with this error:
<Warning>: *** Assertion failure in -[UINib initWithNibName:directory:bundle:], /SourceCache/UIKit/UIKit-3318.16.14/UINib.m:98
Apr 13 23:24:52 Feifan-Zhous-iPad splashboardd[14537]
<Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: (name != nil) && ([name length] > 0)'
The app is in Swift, running on Xcode 6.1.1. The device here is an iPad Mini 4,4 running iOS 8.1 (but the crash happens on all devices including iPhones, ranging from iOS 7.0 upwards).
Notable is the crash happens before the app launches (application:didFinishLaunchingWithOptions: never gets called) and an exception breakpoint in Xcode doesn't catch anything.
The app uses a Main.storyboard file as the Main Interface file. It is not red in the Copy Bundle Resources phase. The app isn't using initWithNibName:directory:bundle anywhere.
Has anyone run into this error and found a fix? Very little to work on

I have an iOS app that runs fine on the simulator, but crashes on all devices
It looks like it must be something with capitalization of a file name. I suppose that you have installed case insensitive file system on your mac so a simulator treats name "File" as "file" (and even "FILE") while iOS devices has case sensitive file systems so file names are case sensitive.
I suppose that you've set incorrectly class name for your initial view controller and it cannot be instantiated.

You are probably initializing a nib name in initWithNibName:directory:bundle which isn't ever being called.
Move the your initialization code from initWithNibName:directory:bundle to awakeFromNib.

I had the same issue, check in the rootViewController/InitialView if you are registering a nib file with a wrong file/reference name. Had that when I registered UICollectionViewCells in viewDidLoad while making a network call, didn't show where the crash was.

Related

iOS App Crashing on iPad Pro only: NSUnknownKeyException

I had a user report my app was freezing at the launch screen on his iPad Pro but working on all other devices -- an iPhone 6 plus and an iPad Mini all runnning iOS 9.2. I've had no crash reports from this release and can also see other iPad devices running the app fine, so I suspected some local file corruption issue. Just as I was writing the user about how to uninstall reinstall, I tried running the app on the iPad Pro simulator. Boom. He was right. Freezes at the Launch screen and throws an exception. (Yes, my inner Bart Simpson is writing 100x on the Blackboard: Test on all simulators before release).
Terminating app due to uncaught exception
'NSUnknownKeyException', reason: '[
setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key view.'
Elsewhere on Stackoverflow this error has been attributed to a bad outlet. As far as I can tell, no issues there:
or a Viewcontroller having a bad class. I'm eliminating that as a candidate as I don't think that would be a single-device failure, and because my app is built in Cordova it hands over to a webview.
The exception gets thrown in main.m, a cordova-generated file:
#import <UIKit/UIKit.h>
int main(int argc, char* argv[])
{
#autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate");
return retVal;
}
}
I'd also read about issues of improperly formatted launch screens causing problems, and since the launch screen image I added for iPad Pro is a new addition to my code since last version, this was my first suspect. But I've checked pixel sizes and resolutions and all my launch screen images comply to the specs at Apple's developer site.
So. Any ideas what about the iPad Pro alone would cause a freeze immediately on launch? The app's first step is to look for a file written to local storage -- and to write one if it doesn't find it. Again, unless there's something very different about how the Pro handles local storage, I don't think that can be it as that process works across all other iOS devices. If running on actual hardware will help anyone diagnose, the app's here in the app store, and I'm happy to send a download code.
This was an embarrassingly simple issue: Don't know how, but the main interface box was scrolled to MainViewController.xib for ipad only. For a Cordova app, it should be blank, which it was in the default iPhone view for the Deployment Info page. When I clicked the iPad button the errant selection was revealed. Blanked it, recompiled, all was well.

Today Extension Crashes before launching on iOS 8.1.2

I've been making a today extension that downloads articles from a feed and display the latest ones.
The whole thing worked fine on iOS 8, still worked on iOS 8.1, then came iOS 8.1.2 and we started having complaints about the today extension not working anymore.
I tried debugging on iOS 8.1.2 devices, and before the extension even launch, it crashes with this error :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: <__NSConcreteUUID 0x174027280> 5AFB07AB-5DCD-46FE-8D07-44DE0F3789F2)'
I have read this post about frequent bugs happening when developing a today extension : http://www.atomicbird.com/blog/ios-app-extension-tip
In his post, Tom Harrington says :
In iOS 8 (and other recent versions), enabling modules in Xcode's build settings means you don't need to explicitly list all the frameworks you want to use. They'll be found automatically.
But this isn't the case with NotificationCenter.framework, which Today extensions use. If you remove that from the build settings, you won't get any build warnings or errors. But when you try to load the extension, you'll get an exception from libextension.dylib and your extension won't load. The exception message is not enlightening:
2014-08-16 12:06:53.793 TodayTestExtension[41313:6111763] * Terminating
app due to uncaught exception 'NSInvalidArgumentException', reason: '*
setObjectForKey: object cannot be nil (key: <__NSConcreteUUID
0x7fd729422390> ED3B42F8-66CD-4CB0-BCD5-F3DBA6F34DB5)'
If you're doing a today extension, just leave that framework in the build settings. It shouldn't need to be there, but it does.
My extension does include NotificationCenter.framework in its build settings, but I suspect my problem might be similar in some way.
Anyone faced a similar problem? Any idea how to solve it?
This error also occurs if you use NSExtensionPrincipalClass inside "Info.plist" in order to define a base class (instead of using a storyboard) with the name of a ViewController which does not exist.
When using Swift, make sure to prefix the class with the module name (usually the name of the target) like "Module.MyViewController".
Eventually I tried to remove NotificationCenter.framework from my target and put it back, cleaned the project, and it's now working again. I guess the framework wasn't properly linked after all, though I could see it on my target with xcode. Also, I can't figure out why it did work, then stopped working with the arrival of 8.1.2.
I fixed this issue by adding the #objc attribute to the Swift class.
#objc(NotificationViewController)
class NotificationViewController: UIViewController, UNNotificationContentExtension {
...
}
Just experienced the same issue. For me, it was "Main Interface" property in "General settings" of the Keyboard target. It was blank, and i set it to my storyboard file and now it works like a charm.

iOS app crashing immediately

My iOS app is crashing immediately without any debug info. I have a break point all objective-c exceptions.
Crashing on this line
return UIApplicationMain(argc, argv, nil, NSStringFromClass([STAppDelegate class]));
App was running fine for the past month and nothing was changed.
I cleaned are re-ran.
What is weird is it is crashing every other time I run so run once its good stop it and run again crashed .... repeat rinse same result... every other time.
I am getting closer after installing 4.6.2. Now it crashes everytime and I get this error."erminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named UIStoryboardUnwindSegueTemplate'"
This is an altogether different story, it looks like a problem similar to use autolayout on iOS version lower than 6.x...
You cannot use storyboard with iOS 5.x as deployment target.
Getting back to your original problem, Xcode 4.6.2 app crashes on every second run, it gets solved either updating to the latest XCode 4.6.3 or using GDB instead of LLDB. I suggest, however, to update to the latest version and hence use LLDB - by the way, it looks like the next XCode 5 will support exclusively LLDB.

iPad app closes after 2 seconds, memory issue?

I made a magazine iPad app so you can scroll through different slides to the left, right, down and up. It's all ready and accepted by the iTunes app store. Problem is, if someone downloads the app it closes directly after 1 seconds of loading.
Weird part is that i installed the app trough xCode and all works without any problems. My guess is that the app takes too much memory. I made a screenshot of the memory instrument:
But how can i release a Srollview if it must be loaded all the time?
Hope someone could push me in the right direction!
I have tested your app on my iPad2 with iOS 5.1.1, and it crash with the following message:
OxygenEvents[97151] <Error>: *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
*** First throw call stack:
(0x375c388f 0x31638259 0x375c3789 0x375c37ab 0x309de54d 0x309de6bb 0x309de423 0x3096f001 0x308dd3c7 0x307bac59 0x30730c17 0x10d5d5 0x30730c8b 0x109beb 0x30730c8b 0x3072f461 0x30721e87 0x307927d5 0x10960b 0x3072fcab 0x307297dd 0x306f7ac3 0x306f7567 0x306f6f3b 0x3771322b 0x37597523 0x375974c5 0x37596313 0x375194a5 0x3751936d 0x3072886b 0x30725cd5 0x10944f 0xf0050)
It is because you use "Autolayout" in your Interface Builder files (nib / xib files), which is an iOS 6.0 only feature.
To solve this, either disable Autolayout in all your xib files like this:
or simply make your app iOS 6.0 only by setting deployment target as iOS 6.0

UITableViewCell behavior in simulator vs. phone

I'm using the 3.1.2 version of the SDK.
I have an app wherein I created a UITableViewCell in IB to display two lines of text per cell. When I run the app in the iPhone simulator, everything works exactly as expected; however, when I run the exact same code on my phone, the app crashes with the following error in the console:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
My iPhone has the 2.2.1 OS and I'm using the 2.2.1 version of the simulator. Also, the code works correctly on my other iPhone running the 3.0 OS when I'm using the latest SDK (3.1.3 beta 2).
My assumption, maybe incorrect, is that the code must be fundamentally correct and there is some nuance with the 2.2.1 OS.
Does this make sense? Has anyone run into this before?
Try to run the app on debug mode on device then check if it works. Because I am also facing this problem and this problem does not occur when running in debug mode.

Resources