locked
Storyboard file crashes the app on device, but works in Simulator RRS feed

  • Question

  • User26928 posted

    I encountered a weird situation. It happens in a specific controller (VendorController), when the app loads the XIB (I use a Storyboard and the rest of the controllers are not affected).

    I can replicate this every tim on the device: 1. Start the app. 2. Open other screens 3. Go to the VendorController screen 4. A breakpoint in the VendorController constructor is hit, continue 5. The app crashes 6. A breakpoint in ViewDidLoad is never reached.

    Here is the crash log. I tried setting a System.Exception breakpoint, but there is none thrown.

    From lines 3-4 below it looks to me like it's searching for some identifier in the XIB that's missing. Neither XCode nor the Xamarin Designer identified any issues with the storyboard, so I'm really stuck here. How can I find out what key is missing? Thank you. Background: I did several changes to a working VendorController in Xcode, that's true, I verified the changes in the simulator. The issue occurs on the device only. It's hard to go back and redo all the changes to isolate the issue (even with git on). Is there another way?

    Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Triggered by Thread: 0

    Last Exception Backtrace: 0 CoreFoundation 0x2fb22f7e exceptionPreprocess + 126 1 libobjc.A.dylib 0x3a2d3cca objcexceptionthrow + 34 2 CoreFoundation 0x2fb22c94 -[NSException raise] + 4 3 Foundation 0x30467f1e -[NSObject(NSKeyValueCoding) setValue:forKey:] + 198 4 Foundation 0x30479b50 -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 296 5 CoreFoundation 0x2fa930e6 -[NSArray makeObjectsPerformSelector:] + 174 6 UIKit 0x326aeeb6 -[UINib instantiateWithOwner:options:] + 1118 7 UIKit 0x32607606 -[UIViewController loadViewFromNibNamed:bundle:] + 230 8 UIKit 0x32463bc8 -[UIViewController loadView] + 88 9 UIKit 0x323442e8 -[UIViewController loadViewIfRequired] + 68 10 UIKit 0x32344264 -[UIViewController view] + 20 11 UIKit 0x324d0366 -[UINavigationController _startCustomTransition:] + 630 12 UIKit 0x323edd5e -[UINavigationController _startDeferredTransitionIfNeeded:] + 414 13 UIKit 0x323edb68 -[UINavigationController _viewWillLayoutSubviews] + 40 14 UIKit 0x323edb00 -[UILayoutContainerView layoutSubviews] + 180 15 UIKit 0x3233fd54 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 376 16 QuartzCore 0x31fbd626 -[CALayer layoutSublayers] + 138 17 QuartzCore 0x31fb8e36 CA::Layer::layoutifneeded(CA::Transaction) + 346 18 QuartzCore 0x31fb8cc8 CA::Layer::layout_and_display_if_needed(CA::Transaction) + 12 19 QuartzCore 0x31fb86da CA::Context::committransaction(CA::Transaction*) + 226 20 QuartzCore 0x31fb84ea CA::Transaction::commit() + 310 21 QuartzCore 0x31fb2218 CA::Transaction::observercallback(CFRunLoopObserver, unsigned long, void) + 52 22 CoreFoundation 0x2faee250 CFRUNLOOPISCALLINGOUTTOANOBSERVERCALLBACKFUNCTION + 16 23 CoreFoundation 0x2faebbf4 CFRunLoopDoObservers + 280 24 CoreFoundation 0x2faebf36 _CFRunLoopRun + 726 25 CoreFoundation 0x2fa56eba CFRunLoopRunSpecific + 518 26 CoreFoundation 0x2fa56c9e CFRunLoopRunInMode + 102 27 GraphicsServices 0x3495c65e GSEventRunModal + 134 28 UIKit 0x323a3148 UIApplicationMain + 1132 29 MyApp 0x00746df8 wrappermanagedtonativeUIKitUIApplicationUIApplicationMainintstringintptrintptr + 268 30 MyApp 0x006d0148 UIKitUIApplicationMainstringintptrintptr (UIApplication.cs:62) 31 MyApp 0x006d0108 UIKitUIApplicationMainstringstringstring (UIApplication.cs:46) 32 MyApp 0x000f926c MyAppApplicationMainstring_ (Main.cs:28) 33 MyApp 0x00974424 wrapperruntimeinvokeobjectruntimeinvokedynamicintptrintptrintptrintptr + 220 34 MyApp 0x01843c02 monojitruntimeinvoke (mini.c:6672) 35 MyApp 0x01890554 monoruntimeinvoke (object.c:2862) 36 MyApp 0x01893c8e monoruntimeexecmain (object.c:4119) 37 MyApp 0x01893ad0 monoruntimerunmain (object.c:3745) 38 MyApp 0x0182dfb4 monojitexec (driver.g.c:1011) 39 MyApp 0x018fa894 xamarinmain (monotouch-main.m:399) 40 MyApp 0x0180bb60 main + 108 41 libdyld.dylib 0x3a7e0ab2 tlvinitializer + 2

    Thursday, July 30, 2015 10:10 AM

Answers

  • User181 posted

    I would expect a log message to identify the name of the property it's trying to set. Most likely you have a connection to an outlet that doesn't exist in code. If you're desperate I think you can override SetValueForUndefinedKey (or SetValueForKey) and look at the key it gives you.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, July 30, 2015 1:15 PM
  • User181 posted
    public override void SetValueForUndefinedKey (NSObject value, NSString undefinedKey)
    {
        base.SetValueForUndefinedKey(value, undefinedKey);
    }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, August 2, 2015 10:59 PM

All replies

  • User181 posted

    I would expect a log message to identify the name of the property it's trying to set. Most likely you have a connection to an outlet that doesn't exist in code. If you're desperate I think you can override SetValueForUndefinedKey (or SetValueForKey) and look at the key it gives you.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, July 30, 2015 1:15 PM
  • User26928 posted

    Thanks @adamkemp, this was probably the reason. I ended up deleting the Xamarin Cache. It then pushed the right build files. I deleted ~/Library/Caches/XamarinStudio-5.0... just in case smb else has the same issue.

    How would you override SetValueForUndefinedKey (or SetValueForKey)?

    Sunday, August 2, 2015 9:56 PM
  • User181 posted
    public override void SetValueForUndefinedKey (NSObject value, NSString undefinedKey)
    {
        base.SetValueForUndefinedKey(value, undefinedKey);
    }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, August 2, 2015 10:59 PM
  • User26928 posted

    Well, obviously this is how you override :), sorry for the dumb question. I wanted to ask where you actually do that. And the answer is simple, in the controller that crashes.

    So actually I could set a breakpoint or print an output message in VendorController. SetValueForUndefinedKey...

    Interesting and simple solution. I did not think of that.

    Tuesday, August 4, 2015 4:50 AM