8

I'm creating bindings for Xamarin.Mac / MonoMac. I'd like to embed the dylib in the generated dll like it's done on Xamarin.iOS with the [LinkWith] attribute.

Is it possible to do that ? if so how ? Or should I load the dylib from the consuming application ? again in this case, how ?

I tried: - dropping the dylib in the Native References folder (doesn't work) - adding a [assembly: MonoMac.RequiredFramework] attribute (doesn't find the dylib)

Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85
  • Did you ever figure out how to do this? I have a .dylib, or a handful of .a that I would like to include in my XamMac project. Adding to the Native References folder seems to do absolutely nothing... – tofutim Feb 06 '14 at 22:40
  • @migueldeicaza once said "we're working on it" – Stephane Delcroix Feb 07 '14 at 07:47

1 Answers1

5

I managed to load the .dylib from the consuming application by doing the following:

  • Add the .dylib to your project as Content
  • add the RequiredFrameworkAttribute:
    [assembly: MonoMac.RequiredFramework("mylib.dylib")]
  • register the assembly from the AppDelegate constructor:
    public partial class AppDelegate : NSApplicationDelegate
    {
        public AppDelegate ()
        {
            Type t = typeof(ATypeFromTheAssembly);
            MonoMac.ObjCRuntime.Runtime.RegisterAssembly (t.Assembly);
        }
    }

That still doesn't embed the .dylib in the bindings assembly, but it qualifies as progress

Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85
  • I've been trying to get libz.dylib to get included - but I think the problem is that libz is Fat (has both i386 and x86_64). – tofutim Feb 07 '14 at 15:45