question

VivekNegi-5459 avatar image
0 Votes"
VivekNegi-5459 asked JarvanZhang-MSFT answered

How to create binding for native swift libary for xamarin forms

I have a Swift library provided by the client, and need to use it in xamarin.forms project. I have gone through https://docs.microsoft.com/en-us/xamarin/ios/platform/binding-swift/walkthrough but its not giving what i required.

According to above link, we need write each and every method which we need to use in xamarin application that is not a good solution, if sdk has 1000 method no developer wants to write and then expose.

For android (java sdk) its very simple to add aar file and compile and it will give you a dll file but for IOS its a very long proces..

Can anyone can help me on this. ? How to create xamarin binding for swift library.

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered

Hello,​

Welcome to our Microsoft Q&A platform!

1.Swift is a newer language and creating bindings for libraries built with this language requires some additional steps and tooling.

we need write each and every method which we need to use in xamarin application that is not a good solution

When preparing the API definition interfaces, these definitions could be created manually or automatically by the Objective Sharpie tool and the generated header file. Check the link: https://docs.microsoft.com/en-us/xamarin/ios/platform/binding-swift/walkthrough#prepare-metadata

Related doc: https://devblogs.microsoft.com/xamarin/binding-ios-swift-libraries/

2.If you want to get a more simpler way to bind a native swift library, you could post a feature request to the product team on github.

Best Regards,

Jarvan Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.