Can we use a native library with in another native library in Xamarin iOS

AroshaCreativeAroshaCreative Member ✭✭

I have a Objective C framework. Using that Objective C framework, I have created a Swift framework. Now I would like to use that Swift framework in Xamarin iOS project. Is that possible?

Once I tried, the application exit without giving any error.

Following things are tested and possible :

  • The Swift framework mentioned above can be used in a Swift project.
  • I know how to bind a Swift framework in a Xamarin iOS project.

Best Answer

  • Accepted Answer

    In such a case, you can find the real reason by going to

    Settings -> Privacy -> Analytics -> Analytics Data -> And find the log file with your bundle ID and the crashed occur date/time.

    The error show to me was related to @rpath/ but actually it solved after signing the bundle with a valid provisioning profile.

    For those who are interesting, you can visit here to find out my experience of implementing this whole scenario mentioned in the title.

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Can we use a native library with in another native library in Xamarin iOS

    Yes.

    You need to reference the another library in your binding project ,the combined set of libraries will be linked into your application.

    Refer to https://stackoverflow.com/a/27073453/8187800 .

  • AroshaCreativeAroshaCreative Member ✭✭

    @ColeX said:

    Can we use a native library with in another native library in Xamarin iOS

    Yes.

    You need to reference the another library in your binding project ,the combined set of libraries will be linked into your application.

    Refer to https://stackoverflow.com/a/27073453/8187800 .

    May be I wasn't clear enough with my question. Let me summarize again.

    • I have a Objective C framework. (This framework is working properly with a Swift project)
    • Then I have a Swift framework. This framework has used the previously mentioned Objective C framework. (This Swift framework also working in a Swift project)
    • Now I am trying to use that Swift framework inside a Xamarin iOS project.
      • I have created a Binding Library project in my Xamarin iOS project and under the Native Reference, I have added both those Swift framework and Objective C framework fat files.
      • I have updated the ApiDefinition file accordingly as well.

    But when I run the application it launch in the phone and exit without giving any error. So I'm clueless what/where went wrong.

  • AroshaCreativeAroshaCreative Member ✭✭
    Accepted Answer

    In such a case, you can find the real reason by going to

    Settings -> Privacy -> Analytics -> Analytics Data -> And find the log file with your bundle ID and the crashed occur date/time.

    The error show to me was related to @rpath/ but actually it solved after signing the bundle with a valid provisioning profile.

    For those who are interesting, you can visit here to find out my experience of implementing this whole scenario mentioned in the title.

  • KingamattackKingamattack Member ✭✭

    Hi,
    I'm facing a similar issue I have a Swift framework that I tried to bind in my Xamarin.iOS project following this tutorial: https://medium.com/@Flash3001/binding-swift-libraries-xamarin-ios-ff32adbc7c76

    My ApiDefinition.cs and Structs.cs are good and I added the dependencies (the .framework files) in both binding project and iOS project under Natives References but when I'm running my app it crashes directly without any logs.

    The app doesn't crash when I don't call classes/methods from the lib, it's only when I try to use it.

    I went to Settings -> Privacy -> Analytics -> Analytics Data on my iPhone but all the logs are outdated and none of them matches my current crashes so I don't really know what to do now. According to the link I but above, I need to add Swift dependencies in my iOS project but even with those (I add all of them Swift3 and Swift4), I still have the same behavior...

    Does someone have some clues?

Sign In or Register to comment.