James Mundy
James Mundy

Reputation: 4329

Xamarin iOS Binding: Could not initialise an instance of the type, returned nil

I've bound an iOS library, SVGKit, to C# using Xamarin/Monotouch. After some issues I've managed to get the library to build ok.

My code can be found here: https://github.com/jamesmundy/SVGKit.Xamarin

Unfortunately, when I try to initialise a type from the class I receive the following error:

Could not initialize an instance of the type 'SVGKitBindings.SVGKFastImageView': the native 'init' method returned nil. It is possible to ignore this condition by setting MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.

The full stack trace is can be seen here.

Any idea as to what is causing this problem and what I can do to rectify it?

Update: Here is the full Build Output of my project. http://pastebin.com/f60wFm52

Update 2: Tried setting SmartLink to false and rebuilding, same error though a slightly different build output. http://pastebin.com/ApCAz2BP

Upvotes: 4

Views: 1718

Answers (1)

Rolf Bjarne Kvinge
Rolf Bjarne Kvinge

Reputation: 19335

Look at the source code for SVGKFastImageView init [1]:

- (id)init
{
    NSAssert(false, @"init not supported, use initWithSVGKImage:");

    return nil;
}

The managed exception is correct: you can't call this constructor.

[1] https://github.com/SVGKit/SVGKit/blob/cd47ae95e57c9490a9238173855ecbe83d4aaf44/Source/UIKit%20additions/SVGKFastImageView.m#L53

Upvotes: 2

Related Questions