How to structure Xamarin library containing iOS & Android bindings?

104 views Asked by At

I'd like to create a library, which can be used within Xamarin projects. I also want to reuse iOS as well as Android libraries (static lib & jar). Therefore I created a solution which contains an Android binding project as well as an iOS binding project.

To expose this functionality I'd like to create a single wrapper class (within a shared project), which forwards the call to the appropriate native lib. I first thought that this could be done with the use of if-makros. Unfortunately, it seems like I can't add references to a shared project, which means I am not able to call the binded methods.

1

There are 1 answers

0
Greg Gammon On

Could you expose an interface in your shared library that each platform implements with their specific binding implementation and reference everything through that?