Search code examples
c#iosxamarinspotifyobjective-sharpie

Objective Sharpie Missing Most of the API


I am trying to get Objective Sharpie to generate the bindings for the Spotify iOS SDK.

I use the following command:

sharpie bind -sdk iphoneos10.2 \
-output SpotifyAuthenticationBindings \
SpotifyAuthentication.framework/Headers/SpotifyAuthentication.h \
-scope SpotifyAuthentication.framework/Headers/ \
-c -F .

However, the outputted ApiDefinitions.cs doesn't seem to contain much outside of the constants:

using Foundation;
using SpotifyAuthentication;
using UIKit;

[Static]
[Verify (ConstantsInterfaceAssociation)]
partial interface Constants
{
    // extern double SpotifyAuthenticationVersionNumber;
    [Field ("SpotifyAuthenticationVersionNumber", "__Internal")]
    double SpotifyAuthenticationVersionNumber { get; }

    // extern const unsigned char [] SpotifyAuthenticationVersionString;
    [Field ("SpotifyAuthenticationVersionString", "__Internal")]
    byte[] SpotifyAuthenticationVersionString { get; }

    // extern NSString *const SPTAuthStreamingScope;
    [Field ("SPTAuthStreamingScope", "__Internal")]
    NSString SPTAuthStreamingScope { get; }

    // extern NSString *const SPTAuthPlaylistReadPrivateScope;
    [Field ("SPTAuthPlaylistReadPrivateScope", "__Internal")]
    NSString SPTAuthPlaylistReadPrivateScope { get; }

    // extern NSString *const SPTAuthPlaylistReadCollaborativeScope;
    [Field ("SPTAuthPlaylistReadCollaborativeScope", "__Internal")]
    NSString SPTAuthPlaylistReadCollaborativeScope { get; }

    // extern NSString *const SPTAuthPlaylistModifyPublicScope;
    [Field ("SPTAuthPlaylistModifyPublicScope", "__Internal")]
    NSString SPTAuthPlaylistModifyPublicScope { get; }

    // extern NSString *const SPTAuthPlaylistModifyPrivateScope;
    [Field ("SPTAuthPlaylistModifyPrivateScope", "__Internal")]
    NSString SPTAuthPlaylistModifyPrivateScope { get; }

    // extern NSString *const SPTAuthUserFollowModifyScope;
    [Field ("SPTAuthUserFollowModifyScope", "__Internal")]
    NSString SPTAuthUserFollowModifyScope { get; }

    // extern NSString *const SPTAuthUserFollowReadScope;
    [Field ("SPTAuthUserFollowReadScope", "__Internal")]
    NSString SPTAuthUserFollowReadScope { get; }

    // extern NSString *const SPTAuthUserLibraryReadScope;
    [Field ("SPTAuthUserLibraryReadScope", "__Internal")]
    NSString SPTAuthUserLibraryReadScope { get; }

    // extern NSString *const SPTAuthUserLibraryModifyScope;
    [Field ("SPTAuthUserLibraryModifyScope", "__Internal")]
    NSString SPTAuthUserLibraryModifyScope { get; }

    // extern NSString *const SPTAuthUserReadPrivateScope;
    [Field ("SPTAuthUserReadPrivateScope", "__Internal")]
    NSString SPTAuthUserReadPrivateScope { get; }

    // extern NSString *const SPTAuthUserReadTopScope;
    [Field ("SPTAuthUserReadTopScope", "__Internal")]
    NSString SPTAuthUserReadTopScope { get; }

    // extern NSString *const SPTAuthUserReadBirthDateScope;
    [Field ("SPTAuthUserReadBirthDateScope", "__Internal")]
    NSString SPTAuthUserReadBirthDateScope { get; }

    // extern NSString *const SPTAuthUserReadEmailScope;
    [Field ("SPTAuthUserReadEmailScope", "__Internal")]
    NSString SPTAuthUserReadEmailScope { get; }

    // extern NSString *const SPTAuthSessionUserDefaultsKey;
    [Field ("SPTAuthSessionUserDefaultsKey", "__Internal")]
    NSString SPTAuthSessionUserDefaultsKey { get; }
}

// typedef void (^SPTAuthCallback)(NSError *, SPTSession *);
delegate void SPTAuthCallback (NSError arg0, SPTSession arg1);

// @interface SPTConnectButton : UIControl
[BaseType (typeof(UIControl))]
interface SPTConnectButton
{
}

How can I make it generate the definitions for all the classes? (ex SPTAuth)


Solution

  • In the SpotifyAuthentication.framework/Headers/SpotifyAuthentication.h, remove the SpotifyAuthentication/ directory from the import statements:

    #import <SPTAuth.h>
    #import <SPTSession.h>
    
    #if TARGET_OS_IPHONE
    #import <SPTConnectButton.h>
    #import <SPTAuthViewController.h>
    #import <SPTStoreViewController.h>
    #import <SPTEmbeddedImages.h>
    #endif
    

    Sharpie:

    sharpie -tlm-do-not-submit \ 
    bind \
    -sdk iphoneos10.2 \
    -output SpotifyAuthenticationBindings \
    SpotifyAuthentication.framework/Headers/SpotifyAuthentication.h \ 
    -c -ISpotifyAuthentication.framework/Header
    

    Your resulting ApiDefinitions.cs should now contain ~300 lines and you will have some cleanup work with the [Verify] tags....