Forum Xamarin.iOS

Question regarding a complex situation with Objective Sharpie

CurtCurt Member

Hello all. I am having an issue getting a framework into a bindable state.

First, a little background... We are currently evaluating several "multiplatform" solutions for rewriting our App Store category-leading app. Given the choices, I really would prefer that we pick Xamarin. We have several Cocoapods in a private spec repo to modularize our app solutions between our other suite of apps. Most of them could easily be refactored into C# .Net Core assemblies, except one. It is a big one, and it drives the behavior of the most important part of our app. Rewriting this one is a non-starter, and if we can't get it into a Xamarin solution, we can't go with Xamarin at all.

I really don't want to do Kotlin Multiplatform...

This particular 'pod is mostly Swift, and the team working on it has tried their hardest to continue to make it mostly Objective C compliant. It is dependent upon two other 'pods. The first is written in C++ with a thin veneer of Swift to get it to easily interface with the main 'pod. The second is a 3rd Party pod that is distributed as a precompiled framework, so no accessing its code there.

Here's what I've tried so far.

I've created a simple iOS app and used Cocoapods to reference the main one. This pulled in the two dependencies. I compiled for Simulator and Device and created fat frameworks for the two that I have control over.

I then tried to create the binding declarations.

sharpie bind Main.framework/Headers/Main-Swift.h  -sdk iphoneos13.2 -namespace Xamarin.Bindings.Main -c -I./Dependency1.framework/Headers -I./ThirdParty.framework/Headers

This gave me this error:

[Bunch of Warnings]
Binding...
348 warnings generated.
  no types were parsed that could be bound

Done. Exiting with error code 1.

Then I tried

sharpie bind -framework Main.framework  -sdk iphoneos13.2 -namespace Xamarin.Bindings.Main -c -F./Dependency1.framework -F./ThirdParty.framework

Same result.

sharpie bind Main.framework/Headers/Main-Swift.h  -sdk iphoneos13.2 -namespace Xamarin.Bindings.Main -c -F./Dependency1.framework -F./ThirdParty.framework

Hey! This actually created my ApiDefs and StructsAndEnums file, but it had this error

Main.framework/Headers/Main-Swift.h:187:9: fatal error: module 'ThirdParty' not found
@import ThirdParty;
 ~~~~~~~^~~~~~

Hope springing eternal, I tried to use this in my Xamarin.iOS Binding Library...

After deleting the 60K extra lines of declarations from my ApiDefinitions and StructsAndEnums files that seemed to be core iOS declarations, I started to fix up some issues in the imports, such as methods being "redeclared" (not really; methods had the same types but different parameter names from swift) and a few strangenesses like

        [Protocol (Name = "MangleMangle-Overlay_")]
        interface Overlay
    {
        ...
    }

    // @interface DefaultOverlay : NSObject <Overlay>
    [BaseType (typeof(NSObject), Name = "MangleMangle-DefaultOverlay")]
    interface DefaultOverlay : IOverlay
    {
        ...
    }

Not sure what do to about this one...

One thing that I can't seem to fix is the missing libraries. Both of these have the red squiggles and I don't know why.

using Main;
using ThirdParty;

I've added the fat binaries to the native references list, set them to "Smart Link" and not "Force Load" and added the iOS frameworks they use. This one is stumping me... Well, this whole process has stumped me, but my alternative is Kotlin, so carry on.

So... My questions... Based on what you see here, what could I be doing wrong? Do I have something wonky in the calls to ObjSharper that just need an extra -I here or -L there?

Hoping y'all can assist, 'cause my alternative is Kotlin.

Sign In or Register to comment.