Sandeep Kumar
Sandeep Kumar

Reputation: 899

How to create bindings for Xamarin.iOS?

I have an iOS static library(.a and headers file), I want to bind this library to Xamarin.iOS

I found the binding steps mention on Xamarin site here and in this walkthrough they use the source code of library. But I have only .a file and headers file.

Is it possible to bind the static library without the source code.

Upvotes: 1

Views: 835

Answers (2)

David S.
David S.

Reputation: 6705

You do not need the source code to bind with Objective Sharpie. All you need is the .a library and the headers.

Here's an example:

sharpie bind -output Binding -sdk iphoneos8.1 \
-scope build/Headers build/Headers/SomeHeader.h \
-c -Ibuild/Headers -arch arm64

Objective Sharpie just output two files: Binding/ApiDefinitions.cs and Binding/StructsAndEnums.cs.

Then you tweak the bindings as needed and run again.

Once the tweaks are complete, these two files can now be added to a binding project in Xamarin Studio or be passed directly to the touch (iOS) or mac (MacOS X) tools to produce the final binding.

Upvotes: 1

Jon Douglas
Jon Douglas

Reputation: 13176

Yes this is possible via Objective Sharpie(https://developer.xamarin.com/guides/cross-platform/macios/binding/objective-sharpie/)

Objective Sharpie uses clang to parse header files which generates quality API definitions. For the things Objective Sharpie cannot parse/generate, you'll need to normalize yourself. These generated files are known as the ApiDefinition.cs and the StructsAndEnums.cs.

To accomplish this, you can use the sharpie bind command.

https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/walkthrough/#Using_Objective_Sharpie

Once you have generated the respective template/scaffolding, you can then pass these items into the bmac/btouch binding tooling which will generate the binding for your platform (Mac/iOS respectfully).

If you're still running into trouble, there's an advanced example here that should also help:

https://developer.xamarin.com/guides/cross-platform/macios/binding/objective-sharpie/examples/advanced/

Upvotes: 1

Related Questions