Objective Sharpie not binding correctly, no methods, only Constants - APIDefs

RyHRyH USMember ✭✭

I am trying to make a binding to an obj-c framework with only an entire laundry list of .h files given. Using Sharpies' -framework flag, I get a few errors about how type definitions are (adding in include <Foundation.Foundation.h> seems to fix those errors). After doing that fix, it echos the following

REDACTED $ sharpie bind -framework WFConnector.framework -sdk iphoneos10.2
Parsing 1 header files...

Binding...
  [write] ApiDefinitions.cs
  [write] StructsAndEnums.cs

Binding Analysis:
  Automated binding is complete, but there are a few APIs which have been flagged with [Verify] attributes. While the entire binding should be audited for best API design
  practices, look more closely at APIs with the following Verify attribute hints:

  ConstantsInterfaceAssociation (6 instances):
    There's no foolproof way to determine with which Objective-C interface an extern variable declaration may be associated. Instances of these are bound as [Field] properties
    in a partial interface into a nearby concrete interface to produce a more intuitive API, possibly eliminating the 'Constants' interface altogether.

  InferredFromMemberPrefix (2 instances):
    The name of this originally anonymous declaration was taken from a common prefix of its members.

  Once you have verified a Verify attribute, you should remove it from the binding source code. The presence of Verify attributes intentionally cause build failures.

  For more information about the Verify attribute hints above, consult the Objective Sharpie documentation by running 'sharpie docs' or visiting the following URL:

    http://xmn.io/sharpie-docs

Submitting usage data to Xamarin...
  Submitted - thank you for helping to improve Objective Sharpie!

Done.

I look into the ApiDefinitions file, and all I see are 6 instances of Constant, all with only string attributes. It does not show any of the methods, or anything else that are in any of the header files in the Headers folder. This is the same whether or not I add include <Foundation.Foundation.h>. I have read this link about how the -framework command works, and I am certain that the folder system is correct (WFConnector.framework/Headers/*.h) and has the umbrella file that does an include on all of the files (WFConnector.framework/Headers/WFConnector.h). In addition, I have tried to run the command with the -scope flag on only the header folder, but all of the files use an angled include (eg include <frameworkName/className>), causing the build to escape with an error.

Any help would be greatly appreciated. Especially @AaronBockover , I have seen him helping a lot of the questions focused on bindings, So I would imagine that he would have an idea of where to go from here. If you would like to look at the library I am trying to do this with, it is the Wahoo Fitness API ( request to download the api , Docs).

Best Answer

  • RyHRyH USMember ✭✭
    Accepted Answer

    I was unable to get this working with framework, So instead, what I did was use the -scope call on the Headers Folder.

    This gave me an error that it could not find the 'namespace' to work with (all files were referred to as #import <WFConnector/*.h> . I wrote up a one line sed command that would make anything that matched it to the format it would accept

    #import <WFConnector/*.h> => #import "*.h"
    From there, it more or less worked. I had to remove a file that used Cocoapods ( the file was unused anyway) and fixed the few points that did not get affected by the command. The command is written below in case anyone wants to take and modify it for use of their own project

    for i in *.h; 
    do
        sed -i '' 's/\(#import\) <WFConnector\/\(.*\)>/\1 "\2"/g' "$i";
    done;
    

    Hope this helps someone down the line.

Answers

  • RyHRyH USMember ✭✭
    Accepted Answer

    I was unable to get this working with framework, So instead, what I did was use the -scope call on the Headers Folder.

    This gave me an error that it could not find the 'namespace' to work with (all files were referred to as #import <WFConnector/*.h> . I wrote up a one line sed command that would make anything that matched it to the format it would accept

    #import <WFConnector/*.h> => #import "*.h"
    From there, it more or less worked. I had to remove a file that used Cocoapods ( the file was unused anyway) and fixed the few points that did not get affected by the command. The command is written below in case anyone wants to take and modify it for use of their own project

    for i in *.h; 
    do
        sed -i '' 's/\(#import\) <WFConnector\/\(.*\)>/\1 "\2"/g' "$i";
    done;
    

    Hope this helps someone down the line.

Sign In or Register to comment.