What do do after running sharpie pod bind? Documentation is extremely lacking

PaulBrennerPaulBrenner USUniversity ✭✭

Hello, I'm trying to bind CKViewPager (ideally I'd want to bind the swift version since it's more up to date, but binding swift projects looks insanely complex).

The issue I'm running into is after binding it with sharpie pod bind, it creates two cs files and a .framework file. The documentation doesn't say what to do after that. And every tutorial I've found uses a .a file to create the Xamarin.iOS binding, but the command doesn't create a .a file.

Anyone know what to do next after using sharpie pod bind to make a binding?

Thanks

Posts

  • NashZhouNashZhou USMember ✭✭✭
    edited June 2017

    I'll document my account of trying to bind an iOS library. Objective Sharpie doesn't create, and isn't suppose to create a .a file. Objective Sharpie only creates 2 of the files you unfortunately. You'll need Xcode in order to get the .a file. Here is a video I found off YouTube that shows how you get the .a file. (It's in the first section of the video)

    Once you get the .a file from Xcode as well as the 2 files (ApiDefinitions.cs and StructsAndEnums.cs), create an iOS binding library and put all the files in that binding library. Your ApiDefinitions and StructsAndEnums files replace the existing files. The .a file goes in the Native Reference folder. The video above, which is fairly recent, really didn't help me with the next parts of the binding.

    Theoretically once you have all 3 files in your bindings, you should be able to hit Run and complete the binding! No...You get errors, and if you don't get an error I say good for you! You need to first look at every Verify attribute in your APIDefinitions and check to make sure Objective Sharpie did its job. I had to change some of Objective Sharpie's MethodToProperty hints because it turned some of the methods in the original library into properties (Brush up on your Objective C knowledge). After you run your library a couple of times, fixing whatever is the error, you should get a working library! All you have to do is get that dll file your binding library just produced, open your iOS project and add that dll into your References folder!

    No...I could get my library to run (which is great), but when I add a reference to my binding library in my actual project I get these "The native class hasn't been loaded" errors. None of those guys helped with what I had because I didn't have this linkwith.cs file (I don't blame them either cause the discussion was from 2013). I had to go back into my binding library, right click on my .a file, click properties, and turn SmartLink to true. (Yes I played with every option I could find until I got a working file)

    You might get more errors than I did or you might get less, though that was my experience binding an iOS library.

  • PaulBrennerPaulBrenner USUniversity ✭✭

    Thanks @NashZhou! That video was very helpful

  • BalinaBlintBalinaBlint USMember ✭✭

    Hi,
    @NashZhou your description is indeed really helpful. How should I build the .a file if I do not have the source .m files?
    The project I'm talking about is https://github.com/AdColony/AdColony-iOS-SDK-3.

  • BalinaBlintBalinaBlint USMember ✭✭

    The ".a" file is actually there in the pod frameworks... it's just not called .a.

    After you run sharpie pod bind, and update yours structs and api all you need to do is:
    Look for a binary file which will be inside your pods .framework directory. In my case it was:

    $ file Pods/AdColony/AdColony.framework/Versions/Current/AdColony
    
    Pods/AdColony/AdColony.framework/Versions/Current/AdColony: Mach-O universal binary with 5 architectures: [arm_v7: current ar archive] [arm_v7s] [i386] [x86_64] [arm64]
    Pods/AdColony/AdColony.framework/Versions/Current/AdColony (for architecture armv7):    current ar archive
    Pods/AdColony/AdColony.framework/Versions/Current/AdColony (for architecture armv7s):   current ar archive
    Pods/AdColony/AdColony.framework/Versions/Current/AdColony (for architecture i386): current ar archive
    Pods/AdColony/AdColony.framework/Versions/Current/AdColony (for architecture x86_64):   current ar archive
    Pods/AdColony/AdColony.framework/Versions/Current/AdColony (for architecture arm64):    current ar archive
    

    for the sake of my soul I did actually create a copy
    cp Pods/AdColony/AdColony.framework/Versions/Current/AdColony ./libAdColonySDK.a

    Then you can simply right click on project, add existing file, and select this .a, the linkwith will be created automatically.

Sign In or Register to comment.