Forum Xamarin.iOS

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Objective-Sharpie help

DeanCleaverDeanCleaver USMember ✭✭✭

I've created or modified bindings projects before, but this time I have to start from scratch (new library) and I can't get Objective-Sharpie to do what I need - I get this error:

/Users/Me/file.h:7:9: fatal error: 'Foundation/Foundation.h' file not found

import <Foundation/Foundation.h>

Any tips on how to correct that? This is not my h file, I do not have the source to compile the project or anything else - just an h and the lib file.

Any help much appreciated.

Posts

  • DeanCleaverDeanCleaver USMember ✭✭✭

    Wow... formatting rather unintentional lol.

  • KMullinsKMullins USMember, Xamarin Team Xamurai

    Hi @DeanCleaver,

    We've just released a new version of the tool and its documentation, which I would suggest taking a look at.

    Off the top of my head, try adding the -scope objective to the Objective Sharpie call. See the Real-World Example section of the doc I linked in a above for more information on its usage.

    Kevin

  • DeanCleaverDeanCleaver USMember ✭✭✭

    Hi @KMullins,

    Unfortunately, that's what I was using and that's what I read. I don't think the scope applies, because it's one single h file - the problem is it includes standard iOS h files (not other h files from it's own project) which are obviously not found by Objective Sharpie - I'm not even 100% sure where they are, or how to point Objective Sharpie to them.

    I tried changing the angle brackets for quotes, and copying the UIKit.h to the a UIKit folder, and Foundation.h to a Foundation folder, but then each of these reference other h files - it was going to be a nightmare.

    I just really don't want to have to hand create all 50 API calls.

    Dino

  • KMullinsKMullins USMember, Xamarin Team Xamurai

    Hi @DeanCleaver,

    No -scope is what you want to be using because you don't want to bind references to #import header files that are bits of the base system like Foundation.h or UIKit.h. Scope limits the binding process to only .h files found in the directory you've specified to the scope command that are directly parts of the library being bound. So the correct usage should be -scope [directory-where-the-library-.h-files-are].

    Objective Sharpie works best against libraries where you have the full source code. In situations where you don't, it is best to do the binding by hand.

    Kevin

  • DeanCleaverDeanCleaver USMember ✭✭✭

    Hi @KMullins,

    I've tried adding scope. I've tried moving the file to a sub folder so I can call it as you have. I have the h file in a folder caller ePOSPrint. This is my call:

    sharpie bind -output ePrint -scope ePOSPrint ePOSPrint/ePOS-Print.h -c -IePOSPrint

    Pretty much an exact duplicate of your call - and I get an error Foundation/Foundation.h not found.

    Dino

  • KMullinsKMullins USMember, Xamarin Team Xamurai

    @DeanCleaver,

    As I stated above, Objective Sharpie works best when you have the all of the source code. So in this case you are more than likely going to have to do the binding by hand.

    Sorry,

    Kevin

  • DeanCleaverDeanCleaver USMember ✭✭✭

    Might just scrap Xamarin and write it in Objective-C - will be faster.

  • DeanCleaverDeanCleaver USMember ✭✭✭

    @KMullins‌ - turns out the solution is to add "-sdk iphoneos8.1" to the call:

    sharpie bind -sdk iphoneos8.1 -output ePrint -scope ePOSPrint ePOSPrint/ePOS-Print.h -c -IePOSPrint

  • KMullinsKMullins USMember, Xamarin Team Xamurai

    Yep, I missed that in you initial post. Glad to see that Aaron could help you out.

  • DeanCleaverDeanCleaver USMember ✭✭✭

    Yeah - and I know your recommendation is to hand code it for ones where we don't have the source, but at least this gives me a solid start, and I can hand tweak as needed.

  • anoopmohanananoopmohanan USMember ✭✭

    @DeanCleaver said:
    @KMullins‌ - turns out the solution is to add "-sdk iphoneos8.1" to the call:

    sharpie bind -sdk iphoneos8.1 -output ePrint -scope ePOSPrint ePOSPrint/ePOS-Print.h -c -IePOSPrint

    Thanks this helped me

  • guilloagguilloag Member ✭✭

    @DeanCleaver You are the hero of the day for me.
    You saved me to lose so many hours trying to figure out what the heck is going on. BTW: It's my first time binding an iOS library, I've done a lot of android libraries and it is ...let's say ... not as hard as with iOS (it never gets easier, no matter how many libraries you've done)

Sign In or Register to comment.