3

I'm attempting to walk through this guide:

https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/walkthrough/

trying to create bindings for this github project:

https://github.com/lminhtm/LMGaugeView

Using Sharpie 3.4.

I am running into the following issues:

  1. I cannot generate a Fat binary with the architectures i386 armv7 x86_64 arm64 because I am building against iOS11. I can only generate a Fat binary with architectures x86_64 and arm64, attempting the others gives me the error message invalid iOS deployment version, iOS 10 is the max deployment target for 32-bit targets. Is this expected?

  2. When I then use Sharpie I am able to generate the API and Struct files, however, each of these files are huge, with Structs ending up at 24K+ lines, and API 54K+ lines. I followed a youtube tutorial as well and the output he got was about 200 or so lines, so the fact that mine are so huge makes me think something is going on. His tutorial wasn't for my same Objective-C project but I even tried the same one he did and ended up with the same result.

  3. The Struct file ends up have over 7K errors, and I see countless lines that look something like:

    // extern long double tanhl (long double) __attribute__((const)) __attribute__((nothrow));
    [DllImport ("__Internal")]
    [Verify (PlatformInvoke)]
    static extern [unsupported Builtin: long double] tanhl ([unsupported Builtin: long double]);
    

Where it's missing identifier names and has this [unsupported Builtin: piece I don't understand.

There's also countless references to other iOS versions, and watchOS and TV, so it seems like it's trying to create the API and Structs for every OS and version there is, which makes sense why the files would be so large. Here's a small snippet from the Struct file:

    // extern CGPathRef _Nullable CGPathCreateCopyByTransformingPath (CGPathRef _Nullable path, const CGAffineTransform * _Nullable transform) __attribute__((availability(ios, introduced=5.0))) __attribute__((cf_audited_transfer));
    [iOS (5,0)]
    [DllImport ("__Internal")]
    [Verify (PlatformInvoke)]
    [return: NullAllowed]
    static extern unsafe CGPathRef* CGPathCreateCopyByTransformingPath ([NullAllowed] CGPathRef* path, [NullAllowed] CGAffineTransform* transform);

    // extern CGMutablePathRef _Nullable CGPathCreateMutableCopy (CGPathRef _Nullable path) __attribute__((availability(ios, introduced=2.0))) __attribute__((cf_audited_transfer));
    [iOS (2,0)]
    [DllImport ("__Internal")]
    [Verify (PlatformInvoke)]
    [return: NullAllowed]
    static extern unsafe CGMutablePathRef* CGPathCreateMutableCopy ([NullAllowed] CGPathRef* path);

    // extern CGMutablePathRef _Nullable CGPathCreateMutableCopyByTransformingPath (CGPathRef _Nullable path, const CGAffineTransform * _Nullable transform) __attribute__((availability(ios, introduced=5.0))) __attribute__((cf_audited_transfer));
    [iOS (5,0)]
    [DllImport ("__Internal")]
    [Verify (PlatformInvoke)]
    [return: NullAllowed]
    static extern unsafe CGMutablePathRef* CGPathCreateMutableCopyByTransformingPath ([NullAllowed] CGPathRef* path, [NullAllowed] CGAffineTransform* transform);

I know these files should be way smaller, especially since the Objective-C code is a single header file. What could I be doing wrong here?

I can provide more details if needed!

sbonkosky
  • 2,537
  • 1
  • 22
  • 31
  • 1
    Do you have latest version of XCode (9) and Sharpie installed? I want to help, have some experience with iOS bindings – Alex Sorokoletov Oct 19 '17 at 03:02
  • 1
    I quickly checked the pod that you mentioned. Turns out, for that you have to have latest XCode and Sharpie (3.4 is current version). You can update sharpie by running `sharpie update`. Then you can generate a binding. I've tried and it seems to work just fine, see yourself: https://www.youtube.com/watch?v=g7qQJnMxubU&feature=youtu.be Tool I used in video is a wrapper for sharpie I use for Xamarin.iOS bindings – Alex Sorokoletov Oct 19 '17 at 03:29
  • 1
    @AlexSorokoletov I can't even begin to express my gratitude for you answering me. I'm using your tool and it worked so perfectly it brought a tear to my eye haha! If there's somewhere I could donate to you please let me know, and if you add this as an answer I will definitely accept it. A million times, THANK YOU!! – sbonkosky Oct 20 '17 at 00:32
  • @AlexSorokoletov Trying another pod, WMGaugeView, Im getting a 404 not found error. I tried a different pod and it worked, seems like something specific to this one. Is there something I need to specify or do for this one? – sbonkosky Oct 20 '17 at 00:58
  • @AlexSorokoletov Looks like it's a 404 from this URL I found thats built in the build.fsx file: https://trunk.cocoapods.org/api/v1/pods/WMGaugeView/specs/latest – sbonkosky Oct 20 '17 at 01:10
  • 1
    Let me see, that might be either outdated cocoapods repo or something else I did not consider in the automatic. Thank you for warm words, made my day :) – Alex Sorokoletov Oct 21 '17 at 13:41
  • 1
    CocoaPods team says it's an issue with their api - for this WMGaugeView pod podspec url is broken. I'll ping you here when it's fixed and you can generate binding. – Alex Sorokoletov Oct 23 '17 at 00:15
  • 1
    Opened issue with cocoapods trunk repo we're using for podspec. https://github.com/CocoaPods/trunk.cocoapods.org/issues/233 Looking for any workarounds for this pod – Alex Sorokoletov Oct 27 '17 at 01:39
  • 1
    @AlexSorokoletov Thank you, Alex! – sbonkosky Oct 27 '17 at 01:58

1 Answers1

3

I quickly checked the LMGaugeView pod that you mentioned.

Turns out, for that you have to have latest XCode and Sharpie (3.4 is current version).

You can update sharpie by running sharpie update. Then you can generate a binding.

I've tried and it seems to work just fine, see yourself: youtube.com/watch?v=g7qQJnMxubU&feature=youtu.be

Shameless plug - tool I used in video is a wrapper for sharpie I use for Xamarin.iOS bindings - objc-automatic.

Alex Sorokoletov
  • 3,102
  • 2
  • 30
  • 52