Sunday, March 26, 2017

How to port swift based cocoapods to Xamarin

Leave a Comment

I am trying to port cocoapods to xamarin.

Objective C based cocoapods can be ported by converting it into a static library(.a) and subsequently converting that as binding library in xamarin studio or visual studio

But Swift based cocoapods can not be converted into a static library and so it can't be ported to xamarin.

but swift can be converted into a dynamic framework but I couldn't find any way to port that to xamarin

Is there any other way to port swift based cocoapods or ios project into xamarin ?

1 Answers

Answers 1

Binding a Swift Library in Xamarin.iOS follows the same process for Objective-C as shown in xamarin documentation

but with some caveats.

  • A swift class must inherit from NSObject to be binded.

  • Swift compiler will translate class and protocol names into something else, so you must specify the final name in the ApiDefinition.

  • In runtime your APP must include some swift core libraries alongside your binded framework in a folder called Frameworks;

  • When the App is pushed to AppStore it must include a SwiftSupport folder alongside your Payload folder. Those are inside the IPA file.

Here you can find a simple sample binding: https://github.com/Flash3001/Xamarin.BindingSwiftLibrarySample

And a full binding sample: https://github.com/Flash3001/iOSCharts.Xamarin

Please find the full documentation of how to do this here

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment