1
  • 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. I'm glad if application crashed with an error. But it doesn't and I'm clueless now. Any thoughts?

Below is how I'm trying to access the methods in those frameworks inside my Xamarin iOS project

using BindingSwift;
// More codes here

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var myClass = new AroshaMathPerformer();
            var result = myClass.DoTheMath;
            Console.WriteLine("# Result = " + result);
        }

But, if I add a breakpoint, it doesn't even hit at the run time before the application exits.

AnujAroshA
  • 4,623
  • 8
  • 56
  • 99

2 Answers2

0

Assuming that everything you did is in the question, then it is expected not to work. Swift libraries are not officially supported on Xamarin.iOS. Some people made them work with these steps: https://medium.com/@Flash3001/binding-swift-libraries-xamarin-ios-ff32adbc7c76

Ivan Ičin
  • 9,672
  • 5
  • 36
  • 57
  • That is a good post. But I have prior experience of using Swift frameworks in Xamarin iOS applications. So I have an understanding about the content that post has as well as I have shared my experience in one of [my blog post](https://anujarosha.wordpress.com/2019/03/27/how-to-create-a-swift-framework-that-is-compatible-with-xamarin-ios/) as well. What I haven't tried was, the Swift framework that I used to bind is having a reference to another third party Objective C framework. My other suspicious point is VS for Mac version and Xcode version mismatching scenario. – AnujAroshA May 26 '19 at 09:06
0

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.

AnujAroshA
  • 4,623
  • 8
  • 56
  • 99