How to create binding for native swift libary for xamarin forms

Vivek Negi 1 Reputation point
2021-07-05T08:23:40.94+00:00

I have a Swift library provided by the client, and need to use it in xamarin.forms project. I have gone through https://learn.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.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,378 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,966 Reputation points
    2021-07-06T06:03:33.17+00:00

    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://learn.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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.