IOS App Update for Xamarin Unified API

I get an exception when I try to run my application, which I upgraded to a unified API, using the automatic upgrade tool in Xamarin Studio. I see that a pop-up screen appears for about a second in the iPhone simulator, and then the following exception is thrown in the main method.

Objective-C exception thrown. Name: NSInvalidArgumentException Reason: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil Native stack trace: 0 CoreFoundation 0x00940a94 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x087ffe02 objc_exception_throw + 50 2 CoreFoundation 0x007ee3a1 -[__NSArrayM insertObject:atIndex:] + 881 3 CoreFoundation 0x007ee001 -[__NSArrayM addObject:] + 65 4 UIKit 0x0342e9b6 -[UINavigationController _navigationItems] + 341 5 UIKit 0x0342c3ac -[UINavigationController initWithCoder:] + 1009 6 UIKit 0x0364c834 -[UIClassSwapper initWithCoder:] + 279 7 UIKit 0x03846e99 UINibDecoderDecodeObjectForValue + 739 8 UIKit 0x03846bae -[UINibDecoder decodeObjectForKey:] + 320 9 UIKit 0x0333a812 -[UINavigationBar initWithCoder:] + 472 10 UIKit 0x03846e99 UINibDecoderDecodeObjectForValue + 739 11 UIKit 0x03846bae -[UINibDecoder decodeObjectForKey:] + 320 12 UIKit 0x0332f9a9 -[UINavigationItem initWithCoder:] + 899 13 UIKit 0x03846e99 UINibDecoderDecodeObjectForValue + 739 14 UIKit 0x03846bae -[UINibDecoder decodeObjectForKey:] + 320 15 UIKit 0x033f217e -[UIViewController initWithCoder:] + 528 16 UIKit 0x03455f5e -[UITabBarController initWithCoder:] + 68 17 UIKit 0x0364c834 -[UIClassSwapper initWithCoder:] + 279 18 UIKit 0x03846e99 UINibDecoderDecodeObjectForValue + 739 19 UIKit 0x03846bae -[UINibDecoder decodeObjectForKey:] + 320 20 UIKit 0x0364c403 -[UIRuntimeConnection initWithCoder:] + 148 21 UIKit 0x03846e99 UINibDecoderDecodeObjectForValue + 739 22 UIKit 0x038470aa UINibDecoderDecodeObjectForValue + 1268 23 UIKit 0x03846bae -[UINibDecoder decodeObjectForKey:] + 320 24 UIKit 0x0364b43d -[UINib instantiateWithOwner:options:] + 1411 25 UIKit 0x039f4ace -[UIStoryboard instantiateViewControllerWithIdentifier:] + 220 26 UIKit 0x039f4c5b -[UIStoryboard instantiateInitialViewController] + 78 27 UIKit 0x032355e7 -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 99 28 UIKit 0x03235964 -[UIApplication _loadMainInterfaceFile] + 292 29 UIKit 0x03233d35 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1575 30 UIKit 0x03257905 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3171 + 68 31 UIKit 0x03230bae -[UIApplication workspaceDidEndTransaction:] + 163 32 FrontBoardServices 0x0b013ccc __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71 33 FrontBoardServices 0x0b0137a3 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54 34 FrontBoardServices 0x0b0311cb -[FBSSerialQueue _performNext] + 184 35 FrontBoardServices 0x0b031602 -[FBSSerialQueue _performNextFromRunLoopSource] + 52 36 FrontBoardServices 0x0b0308fe FBSSerialQueueRunLoopSourceHandler + 33 37 CoreFoundation 0x0085ae7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 38 CoreFoundation 0x00850b0b __CFRunLoopDoSources0 + 523 39 CoreFoundation 0x0084ff28 __CFRunLoopRun + 1032 40 CoreFoundation 0x0084f866 CFRunLoopRunSpecific + 470 41 CoreFoundation 0x0084f67b CFRunLoopRunInMode + 123 42 UIKit 0x03230497 -[UIApplication _run] + 540 43 UIKit 0x03235cc1 UIApplicationMain + 160 44 ??? 0x17eb7288 0x0 + 401306248 45 ??? 0x17eb7080 0x0 + 401305728 46 ??? 0x17eb5210 0x0 + 401297936 47 ??? 0x17eb4f48 0x0 + 401297224 48 ??? 0x17eb50d8 0x0 + 401297624 49 myAppiOS 0x00207d9b mono_jit_runtime_invoke + 715 50 myAppiOS 0x002a66ef mono_runtime_invoke + 127 51 myAppiOS 0x002ab8e1 mono_runtime_exec_main + 401 52 myAppiOS 0x002ab697 mono_runtime_run_main + 711 53 myAppiOS 0x00167fad mono_jit_exec + 93 54 myAppiOS 0x00384bd1 xamarin_main + 2497 55 myAppiOS 0x00385562 main + 114 56 libdyld.dylib 0x08cd9a21 start + 1 57 ??? 0x00000003 0x0 + 3 

This is in the main Main method:

 using System.Collections.Generic; using System.Linq; using Foundation; using UIKit; namespace myAppiOS { public class Application { // This is the main entry point of the application. static void Main (string[] args) { // if you want to use a different Application Delegate class from "AppDelegate" // you can specify it here. UIApplication.Main (args, null, "AppDelegate"); } } } 

Any ideas?

+7
c # ios xamarin
source share
1 answer

I have only troubleshooting tips.

The problem is the third line of StackTrace:

2 CoreFoundation 0x007ee3a1 - [__ NSArrayM insertObject: atIndex :] + 881

Obviously you are adding an element, and the libobjc.A.dylib thing is cloning itself:

1 libobjc.A.dylib 0x087ffe02 objc_exception_throw + 50 2

To diagnose the root cause, you need the classic ASP troubleshooting methodology. Debug.Print applications are everywhere!

You literally have to look for your code for where you add items to the collection. And this somewhere will probably be in the call to instantiateViewControllerWithIdentifier .

Since an exception is thrown before you can execute the code , the only option (other than debugging a memory dump) is to comment or Debug.Print all calls to narrow down the problem! In sequence: (

Its such a PITA and I sympathize with you . I believe that due to adding a null object in accordance with the error message, the object cannot be nil

It could be anything, but adding zero is probably a symptom of another problem. Maybe the element you are adding is too big, maybe it exceeds the bounds of the array, maybe you just need to clear the solution and redistribute it.

Perhaps trying to include exceptions may help if you can UIApplication.Main (args, null, "AppDelegate"); e.g. fooobar.com/questions/830914 / ...

+1
source share

All Articles