简体   繁体   中英

Create binding for 2 dependent static libraries in Xamarin.iOS

I have an issue with binding on Xamarin.iOS.

I have 2 libraries: libA.a libB.a

And libB.a is depend on libA.a classes. In libA I have this class:

namespace ABC {
    [BaseType (typeof (NSObject))]
    public partial interface ClassAbc {
        [Export ("setString:")]
        void SetString (string abc);
    }
}

And in libB I have this code:

namespace ABCUsage {
    [BaseType (typeof (NSObject))]
    public partial interface ClassAbcUsage {
        [Export ("setAbc:")]
        void SetAbc (ClassAbc abc);
    }
}

I have no source code of libA.a and libB.a but only universal static libraries and headers.

I tried to add libA binding project and final A.dll as a Reference for libB binding but it says "namespace ABC not found".

How should I make a correct binding for libB?

Hello you can bind as many libraries as you want in a single binding project, just make sure you specify fully qualified type names

namespace ABC {
    [BaseType (typeof (NSObject))]
    public partial interface ClassAbc {
        [Export ("setString:")]
        void SetString (string abc);
    }
}

namespace ABCUsage {
    [BaseType (typeof (NSObject))]
    public partial interface ClassAbcUsage {
        [Export ("setAbc:")]
        void SetAbc (ABC.ClassAbc abc);
                    //^^^^^
    }
}

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM