Embed dylib in Xamarin.Mac binding dll

做~自己de王妃 提交于 2019-12-05 22:11:51

问题


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)


回答1:


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



来源:https://stackoverflow.com/questions/15271877/embed-dylib-in-xamarin-mac-binding-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!