Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Native iOS library binding

I have an iOS native library which depends on a pure c code, can i make a binding to this library even though it depends on c code?


  • GuillermoGutierrezGuillermoGutierrez ESMember ✭✭✭

    Yes, you can bind any Obj-C library, just make sure to link the required C library or it will crash.

  • The problem is that I haven't be able to parse the header files in order to generate the ApiDefinition. Could I have some help in this process?

  • GuillermoGutierrezGuillermoGutierrez ESMember ✭✭✭

    Are you trying to process C header files? You can only bind Objective-C library. More information here.

  • Ok, let me explain my entire problem. We have an application which was developed on Xamarin, but now we need to integrate a device on it. The driver for the communication with this device was written using objective-c but it also depends on a c code. We have "mylib.h" (written using objective-c) and "mylibC.h" (written using c). "mylib.h" makes function calls to "mylibC.h". We also have an ".a" file which is the library.
    We need to link the ".a" file to our application in order to use the device, but when we try to generate the ApiDefinition we get a lot of errors.
    My question is: Can we make this binding? Is it possible to bind to that kind of library (which depends on c code)?


  • GuillermoGutierrezGuillermoGutierrez ESMember ✭✭✭

    AFAIK you can do that binding as you usually do with any other library. The public header for your Objective-C library "mylib.h" is the one that should be bound. Just ignore the internal C header "mylibC.h", it's internally used from your Obj-C library, but there's not need to bind it because it won't be called directly from C#.

    After creating the binding project, compile the DLL linking both Obj-C and C .a libraries into a Xamarin.iOS DLL.

Sign In or Register to comment.