Search code examples
xamarin.iosswift-frameworkobjective-c-framework

Using an Objective C framework, which is inside a Swift framework, in a Xamarin iOS project


  • 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.


Solution

  • 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.