I'm trying to create bindings for GPUImage project, but none of binded classes is working. For example, GPUImageView:
In ObjC it's declared like this (header in git):
@interface GPUImageView : UIView <GPUImageInput>
//then some fields, properties and methods I'm not interested in
So, my ApiDefinition.cs looks like this:
namespace GPUImage
{
[BaseType (typeof(NSObject))]
[Model]
interface GPUImageInput {
}
[BaseType (typeof(UIView))]
interface GPUImageView : GPUImageInput {
[Export ("initWithFrame:")]
IntPtr Constructor(RectangleF frame);
}
}
LinkWithAttributes:
[assembly: LinkWith ("libGPUImage.a", LinkTarget.Simulator | LinkTarget.ArmV7 | LinkTarget.ArmV7s, ForceLoad = true, Frameworks = "CoreMedia CoreVideo OpenGLES QuartzCore AVFoundation UIKit Foundation")]
It builds ok and creates dll. But when I try to use it in my project like this:
var iv = new GPUImageView (new RectangleF (0, 0, 100, 100));
Exception throwed:
Could not create an native instance of the type 'GPUImage.GPUImageView': the native class hasn't been loaded. It is possible to ignore this condition by setting Class.ThrowOnInitFailure to false.
Stacktrace
After MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure == false
iv
was created, but unusable (e.g. AddSubview(iv)
show nothing).
I suppose there is something wrong with GPUImage.a file, but I don't know how to test it in any way.
Here is 7z with 2 projects in it: TryingBindings -- bindings themselves; TryingGPUImage -- bindings in use;
Thanks in advance.
P.S. Here is the link to this post on xamarin forums.
Thanks to Rolf Bjarne Kvinge
There are two problems:
1) The file with the LinkWith attribute (libGPUImage.linkwith.cs) is not compiled. Just right-click the TryingBindings project, Add, Add files and select it.
2) The native library does not contain code for i386 (simulator), only arm (device). If you're building the native library yourself you can either create a universal library that contain code for all the architectures, or you can use several native libraries, each supporting a different set of architectures, and just have a LinkWith attribute for each native library.
Bug 11497
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With