Xamarin iOS binding library works on iPhone but not on iPhone simulator

LukePothierLukePothier USMember ✭✭
edited June 2018 in Xamarin.iOS

I have a binding library which wraps a .framework library. I also have an app with a reference to the binding project. When I run the app on an iPhone, I have no issues. When I run the app on a simulator the project builds, but as soon as I call a method from the binding project I get a SIGABRT:

Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: *** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: )
Native stack trace:
    0   CoreFoundation                      0x00000001125e512b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x0000000115753f41 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001126250cc _CFThrowFormattedException + 194
    3   CoreFoundation                      0x00000001124f974a -[__NSDictionaryM setObject:forKey:] + 986
    4   XXX.Demo.Native.iOS                 0x000000010fc97f79 -[XXX_DitarStream instanceWithIdentifier:] + 236
    5   XXX.Demo.Native.iOS                 0x000000010fc90bab +[XXXSDK instanceWithIdentifier:] + 83
    6   XXX.Demo.Native.iOS                 0x00000001100ba8f9 xamarin_dyn_objc_msgSend + 217
    7   ???                                 0x0000000133d60413 0x0 + 5164631059

The crash happens at the .NET call to the native instanceWithIdentifier: method.

Everything I've tried has failed to make a difference:

Re-doing the binding project with a fat binary instead of a dynamic framework
Changing simulators and simulator iOS versions
Removing assembly linking on the app
Adding --registrar:dynamic to the MTouch arguments for the app

No matter which of the above combinations I try, the SIGABRT is the same.


  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai


    Can you verify that the binary for the framework is indeed built for i386/x86_64? You can use the file commend in Terminal to verify:

    file /path/to/binary

    However the exception you are showing does not seem to be an architecture issue, but worth double checking anyway.

    Is there something in the library that may be using a feature that is not supported on the simulator, like the Camera? The error is that after the call to instanceWithIdentifier: iOS is trying to set an object for a key in a NSDictionary, but the key is null

    NSInvalidArgumentException Reason: *** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: )

    but I have no idea why that might knowing nothing about the framework and what is might be doing.

  • LukePothierLukePothier USMember ✭✭

    Hi @JGoldberger, thanks for the response.

    The fat binary includes i386 and x86_64 thin binaries.

    There library doesn't do anything that's not supported on a simulator, I'm using the same framework in an objective C app without issue. I don't have access to the source code of the binary but I know that it's making network calls inside the instanceWithIdentifier function.

    Is there anything else I can try?

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    Nothing off the top of my head. I would have to look over the project. I PM'd you.

Sign In or Register to comment.