【问题标题】:Objective Sharpie Missing Most of the APIObjective Sharpie 缺少大部分 API
【发布时间】:2017-07-21 11:08:19
【问题描述】:

我正在尝试让 Objective Sharpie 为 Spotify iOS SDK 生成绑定。

我使用以下命令:

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

但是,输出的ApiDefinitions.cs 似乎没有包含太多常量之外的内容:

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
{
}

如何让它为所有类生成定义? (ex SPTAuth

【问题讨论】:

    标签: c# ios xamarin spotify objective-sharpie


    【解决方案1】:

    SpotifyAuthentication.framework/Headers/SpotifyAuthentication.h 中,从import 语句中删除SpotifyAuthentication/ 目录:

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

    夏普:

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

    您生成的ApiDefinitions.cs 现在应该包含约 300 行,并且您将使用 [Verify] 标记进行一些清理工作......

    【讨论】:

    • 我的ApiDefinitions.cs 在这之后有 317 行,但乍一看似乎是完整的。谢谢!
    • @DanielCentore 我在现有的 ApiDef.cs 上做了一个 wc -c 而不是 wc -l,需要更多的咖啡... ;-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多