Xamarin DFU Library

We have been trying to create a binding library for Xamarin based on the DFU library at: https://github.com/NordicSemiconductor/IOS-Pods-DFU-Library

So, far, we were able to extract and build the library using Carthage, but in order to use it in in a binding library for iOS, the ApiDefinition.h and struct.h files must be generated.
For that I used sharpie:

     sharpie bind -sdk iphoneos11.3 iOSDFULibrary.framework/headers/iOSDFULibrary-Swift.h

The files generated by that command (attached) are huge and have tons of errors.
Do you know of any other method to create the iOS binding library for Xamarin?

Thanks.

ApiDefinition.csStructs.cs

Parents Reply
  • Please see attached files below.

    Using latest Sharpie version (3.4.0) and 11.2 SDK.
    Also, tried 2 different ways::

        sharpie bind -sdk iphoneos11.2 iOSDFULibrary.framework

     and 

        sharpie bind iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h -sdk iphoneos11.2

    Both returned errors.

    Framework_With_11_2.txt
    sharpie bind -framework iOSDFULibrary.framework -sdk iphoneos11.2
    
    
    Parsing 1 header files...
    While building module 'iOSDFULibrary' imported from /private/var/folders/n_/zsy64z_s5kd0mwx2klwyzgyh0000gr/T/com.xamarin.ObjectiveSharpie/c93f728faa284279825a579070239746.h:1:
    In file included from <module-includes>:2:
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:235:1: error: 
          unexpected '@' in program
    @objc(DFUFirmwareSize);
    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:248:41: error: unknown
          type name 'DFUFirmwareSize'; did you mean 'DFUFirmware'?
    @property (nonatomic, readonly, strong) DFUFirmwareSize * _Nonnull size;
                                            ^~~~~~~~~~~~~~~
                                            DFUFirmware
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:240:12: note: 
          'DFUFirmware' declared here
    @interface DFUFirmware : NSObject
               ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:375:1: error: 
          unexpected '@' in program
    @objc(CBPeripheral);
    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:376:1: error: 
          unexpected '@' in program
    @objc(NSNumber);
    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:377:1: error: 
          unexpected '@' in program
    @objc(CBUUID);
    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:412:17: error: 
          expected a type
    - (BOOL)select:(CBPeripheral * _Nonnull)peripheral advertisementData:(N...
                    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:425:12: error: unknown
          type name 'CBUUID'; did you mean 'NSUUID'?
    - (NSArray<CBUUID *> * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuSer...
               ^~~~~~
               NSUUID
    /Applications/Xcode9_2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUUID.h:14:12: note: 
          'NSUUID' declared here
    @interface NSUUID : NSObject <NSCopying, NSSecureCoding>
               ^
    While building module 'iOSDFULibrary' imported from /private/var/folders/n_/zsy64z_s5kd0mwx2klwyzgyh0000gr/T/com.xamarin.ObjectiveSharpie/c93f728faa284279825a579070239746.h:1:
    In file included from <module-includes>:2:
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:425:48: error: 
          expected a type
    - (NSArray<CBUUID *> * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuSer...
                                                   ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:432:17: error: 
          expected a type
    - (BOOL)select:(CBPeripheral * _Nonnull)peripheral advertisementData:(N...
                    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:433:12: error: unknown
          type name 'CBUUID'; did you mean 'NSUUID'?
    - (NSArray<CBUUID *> * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuSer...
               ^~~~~~
               NSUUID
    /Applications/Xcode9_2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUUID.h:14:12: note: 
          'NSUUID' declared here
    @interface NSUUID : NSObject <NSCopying, NSSecureCoding>
               ^
    While building module 'iOSDFULibrary' imported from /private/var/folders/n_/zsy64z_s5kd0mwx2klwyzgyh0000gr/T/com.xamarin.ObjectiveSharpie/c93f728faa284279825a579070239746.h:1:
    In file included from <module-includes>:2:
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:433:48: error: 
          expected a type
    - (NSArray<CBUUID *> * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuSer...
                                                   ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:519:1: error: 
          unexpected '@' in program
    @objc(CBCentralManager);
    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:647:49: error: 
          expected a type
    - (nonnull instancetype)initWithCentralManager:(CBCentralManager * _Non...
                                                    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:647:100: error: 
          expected a type
      ...* _Nonnull)centralManager target:(CBPeripheral * _Nonnull)target OBJC_D...
                                           ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:714:49: error: 
          expected a type
    - (nonnull instancetype)initWithCentralManager:(CBCentralManager * _Non...
                                                    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:714:100: error: 
          expected a type
      ...* _Nonnull)centralManager target:(CBPeripheral * _Nonnull)target OBJC_D...
                                           ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:763:49: error: 
          expected a type
    - (nonnull instancetype)initWithCentralManager:(CBCentralManager * _Non...
                                                    ^
    ./iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:763:100: error: 
          expected a type
      ...* _Nonnull)centralManager target:(CBPeripheral * _Nonnull)target OBJC_D...
                                           ^
    While building module 'iOSDFULibrary' imported from /private/var/folders/n_/zsy64z_s5kd0mwx2klwyzgyh0000gr/T/com.xamarin.ObjectiveSharpie/c93f728faa284279825a579070239746.h:1:
    <module-includes>:1:1: warning: umbrella header for module 'iOSDFULibrary' does
          not include header 'iOSDFULibrary-Swift - Copy.h' [-Wincomplete-umbrella]
    #import "Headers/iOSDFULibrary-iOS-umbrella.h"
    ^
    /private/var/folders/n_/zsy64z_s5kd0mwx2klwyzgyh0000gr/T/com.xamarin.ObjectiveSharpie/c93f728faa284279825a579070239746.h:1:9: fatal error: 
          could not build module 'iOSDFULibrary'
    @import iOSDFULibrary;
     ~~~~~~~^~~~~~~~~~~~~
    
    Binding...
    1 warning and 19 errors generated.
    Error while processing /private/var/folders/n_/zsy64z_s5kd0mwx2klwyzgyh0000gr/T/com.xamarin.ObjectiveSharpie/c93f728faa284279825a579070239746.h.
    
    Done. Exiting with error code 1.
    error: Clang failed to parse input and exited with code 1
    
    FileOnly_With_11_2.txt
    sharpie bind iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h -sdk iphoneos11.2
    
    
    Parsing 1 header files...
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:235:1: error: 
          unexpected '@' in program
    @objc(DFUFirmwareSize);
    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:248:41: error: 
          unknown type name 'DFUFirmwareSize'
    @property (nonatomic, readonly, strong) DFUFirmwareSize * _Nonnull size;
                                            ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:248:1: error: 
          property with 'retain (or strong)' attribute must be of object type
    @property (nonatomic, readonly, strong) DFUFirmwareSize * _Nonnull size;
    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:375:1: error: 
          unexpected '@' in program
    @objc(CBPeripheral);
    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:376:1: error: 
          unexpected '@' in program
    @objc(NSNumber);
    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:377:1: error: 
          unexpected '@' in program
    @objc(CBUUID);
    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:412:17: error: 
          expected a type
    - (BOOL)select:(CBPeripheral * _Nonnull)peripheral advertisementData:(N...
                    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:425:12: error: 
          unknown type name 'CBUUID'
    - (NSArray<CBUUID *> * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuSer...
               ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:425:48: error: 
          expected a type
    - (NSArray<CBUUID *> * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuSer...
                                                   ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:432:17: error: 
          expected a type
    - (BOOL)select:(CBPeripheral * _Nonnull)peripheral advertisementData:(N...
                    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:433:12: error: 
          unknown type name 'CBUUID'
    - (NSArray<CBUUID *> * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuSer...
               ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:433:48: error: 
          expected a type
    - (NSArray<CBUUID *> * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuSer...
                                                   ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:519:1: error: 
          unexpected '@' in program
    @objc(CBCentralManager);
    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:647:49: error: 
          expected a type
    - (nonnull instancetype)initWithCentralManager:(CBCentralManager * _Non...
                                                    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:647:100: error: 
          expected a type
      ...* _Nonnull)centralManager target:(CBPeripheral * _Nonnull)target OBJC_D...
                                           ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:714:49: error: 
          expected a type
    - (nonnull instancetype)initWithCentralManager:(CBCentralManager * _Non...
                                                    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:714:100: error: 
          expected a type
      ...* _Nonnull)centralManager target:(CBPeripheral * _Nonnull)target OBJC_D...
                                           ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:763:49: error: 
          expected a type
    - (nonnull instancetype)initWithCentralManager:(CBCentralManager * _Non...
                                                    ^
    /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h:763:100: error: 
          expected a type
      ...* _Nonnull)centralManager target:(CBPeripheral * _Nonnull)target OBJC_D...
                                           ^
    
    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 (112 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.
    
      MethodToProperty (125 instances):
        An Objective-C method was bound as a C# property due to convention
        such as taking no parameters and returning a value (non-void return).
        Often methods like these should be bound as properties to surface a
        nicer API, but sometimes false-positives can occur and the binding
        should actually be a method.
    
      StronglyTypedNSArray (23 instances):
        A native NSArray* was bound as NSObject[]. It might be possible to
        more strongly type the array in the binding based on expectations set
        through API documentation (e.g. comments in the header file) or by
        examining the array contents through testing. For example, an NSArray*
        containing only NSNumber* instances can be bound as NSNumber[] instead
        of NSObject[].
    
      PlatformInvoke (4226 instances):
        In general P/Invoke bindings are not as correct or complete as
        Objective-C bindings (at least currently). You may need to fix up the
        library name (it defaults to '__Internal') and return/parameter types
        manually to conform to C calling conventionsfor the target platform.
        You may find you don't even want to expose the C API in your binding,
        but if you do, you'll probably also want to relocate the definition to
        a more appropriate class and expose a stronger type-safe wrapper. For
        P/Invoke guidance, see http://www.mono-project.com/docs/advanced/
        pinvoke/.
    
      InferredFromMemberPrefix (27 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
    19 errors generated.
    Error while processing /Users/mario.raposo/Documents/Carthage/Build/iOS/iOSDFULibrary.framework/Headers/iOSDFULibrary-Swift.h.
    
    Done. Exiting with error code 1.
    error: Clang failed to parse input and exited with code 1
    C51296:iOS mario.raposo$ 
    

Children
No Data