Binding to Swift Framework

DavePilks_zaDavePilks_za USMember ✭✭

I am trying to integrate a service into an app for a client. Unfortunately the SDK is a framework written in Swift and only Swift. I have managed to reach out to the developers and they have made the code as Objective-C accessible as possible.

The problem is that I now need to create a binding library for this SDK. I see that there are cases of people in the past that have bound directly to Swift cocoapods (I cant find any about frameworks). I tried to bind to the xxx-Swift.h header but that just fell apart.

Is there any way that I can bind to this library directly?

If not, I am considering creating an Objective-C framework, adding the Swift framework to that, and then using this wrapper in the binding library.

Surely someone out there has found a way to do this?

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Of course, you could bind the swift code directly. Refer to this blog: https://medium.com/@Flash3001/binding-swift-libraries-xamarin-ios-ff32adbc7c76 for more details.

  • JJBHATTJJBHATT INMember ✭✭

    Hi @DavePilks_za , wanted to know how you were able to bind the Swift library with Xamarin?

  • EsamSherifEsamSherif EGUniversity ✭✭

    I believe till now there is no official support binding a swift library.

    For the unofficial support...
    As for a swift SDK developer... he can choose to support Objective-C or not.

    If Objective-C is supported then the swift SDK can be imported to any Objective-C project... only then you can follow the medium link referred by @LandLu .

    If Objective-C is not supported, then i believe there is noway to add to Objective-C project hence noway to add it to Xamarin project as well.

Sign In or Register to comment.