3

I have an Obj-C native library libCMX.a that I wish to create C# bindings for, but the library has multiple dependencies, e.g. JASidePanels with a couple of .m and .h files.

How can I include these in the Xamarin binding project so they are linked correctly into the resulting DLL?

I know I can specify Frameworks in the LinkWith attribute, but how do I include pure code dependencies in form of main and header files?

EDIT: The library is proprietary (Cisco CMX SDK), I do not have access to the source code.

EDIT 2: The library is part of a framework (CMX.framework), from which I have extracted the extensionless archive and renamed it to libCMX.a to match default library naming for Xamarin.

Geir Sagberg
  • 9,632
  • 8
  • 45
  • 60

2 Answers2

6

You can reference multiple native libraries in your binding project, the combined set of libraries will be linked into your application.

You only need to surface the APIs for libraries that you want to invoke/call. For the rest, just include the binary dependencies.

miguel.de.icaza
  • 32,654
  • 6
  • 58
  • 76
  • So I would create a static library with the JASidePanels .m and .h-files? Will give it a shot. – Geir Sagberg Nov 24 '14 at 11:28
  • I ended up creating a separate static library with all necessary third-party dependencies, and then linking both libraries in the iOS Binding project. Used the makefile from http://stackoverflow.com/a/19030872/500976 to create a universal binary for iPhone and simulator. – Geir Sagberg Nov 24 '14 at 14:16
1

You will need to compile those into the static library (libMyLibrary.a) you are binding to C#.

SKall
  • 5,234
  • 1
  • 16
  • 25
  • Unfortunately I do not have access to the source code, as it is proprietary (Cisco CMX SDK). Would it be possible to create a new static library that combines this one with its dependencies? – Geir Sagberg Nov 18 '14 at 17:26
  • Are you sure the dependencies have not already been compiled into the library? If this is an iOS lib then they should already be in there as iOS does not allow 3rd party dynamic dependencies. – SKall Nov 18 '14 at 17:50
  • The library is part of a framework (CMX.framework). The sample app I have seen uses the framework directly, and also uses the JASidePanels .m- and -.h files in the iOS project, so it would seem the dependencies have not been compiled into the library. Also, the framework has no headers inside for the third party dependencies, only for the CMX SDK. – Geir Sagberg Nov 18 '14 at 20:33
  • Maybe I could rather create a new Framework that includes the CMX.framework and also the third party dependencies, would that work? As you can tell, I don't have much experience with Xcode development... – Geir Sagberg Nov 18 '14 at 20:39