1

I'm binding a iOS SDK. But the Sharpie confused about this

@interface ALBBQuPaiService : NSObject<ALBBQuPaiService>

The last ALBBQuPaiService is @protocol ALBBQuPaiService

I have tried to change ApiDefinition code like this:

[Protocol(Name = "ALBBQuPaiService"), Model]
interface ALBBQuPaiServiceProtocol
{
     ...
}

[BaseType (typeof(NSObject), Name = "ALBBQuPaiService")]
interface ALBBQuPaiService : ALBBQuPaiServiceProtocol
{
    // +(instancetype)sharedService;
    [Static]
    [Export ("sharedService")]
    ALBBQuPaiService SharedService ();

    // @property (nonatomic, weak) id<QupaiSDKDelegate> _Nullable delegte;
    [NullAllowed, Export ("delegte", ArgumentSemantic.Weak)]
    QupaiSDKDelegate Delegte { get; set; }
}

Finally, I got runtime time exception: unrecognized selector sent to instance 0x7c73f740

Any body can help me? Thanks in advance.

My SDK link

------------------- Update 1: add header file code -------------------------

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSInteger,QupaiSDKWatermarkPosition){
    QupaiSDKWatermarkPositionTopRight,
    QupaiSDKWatermarkPositionBottomRight,
};

typedef NS_ENUM(NSInteger,QupaiSDKCameraPosition){
    QupaiSDKCameraPositionBack,
    QupaiSDKCameraPositionFront,
};

@protocol QupaiSDKDelegate;

@protocol ALBBQuPaiService

-(NSString *) getSdkConfigVersion:(NSString *) platformName
                   sdkVersion:(NSString *) sdkVersion;

-(void) getSdkConfigVersion:(NSString *) platformName
                 sdkVersion:(NSString *) sdkVersion
                    success:(void (^)(NSString *rpcResult))success
                    failure:(void (^)(NSError *rpcError))failure;

@property (nonatomic, weak) id<QupaiSDKDelegate> delegte;

@property (nonatomic, assign) BOOL      enableBeauty;                       
@property (nonatomic, assign) BOOL      enableImport;                       
@property (nonatomic, assign) BOOL      enableMoreMusic;                    
@property (nonatomic, assign) BOOL      enableVideoEffect;                  
@property (nonatomic, assign) BOOL      enableWatermark;                    
@property (nonatomic, assign) CGFloat   thumbnailCompressionQuality;        
@property (nonatomic, strong) UIColor   *tintColor;                         
@property (nonatomic, strong) UIImage   *watermarkImage;                    
@property (nonatomic, assign) QupaiSDKWatermarkPosition   watermarkPosition;
@property (nonatomic, assign) QupaiSDKCameraPosition   cameraPosition;     

- (UIViewController *)createRecordViewControllerWithMinDuration: (CGFloat)minDuration
                                                maxDuration:(CGFloat)maxDuration
                                                    bitRate:(CGFloat)bitRate;

- (UIViewController *)createRecordViewController;


- (void)updateMoreMusic;

@end

@protocol QupaiSDKDelegate <NSObject>

- (void)qupaiSDK:(id<ALBBQuPaiService>)sdk compeleteVideoPath:(NSString *)videoPath thumbnailPath:(NSString *)thumbnailPath;

@optional
- (NSArray *)qupaiSDKMusics:(id<ALBBQuPaiService>)sdk;
- (void)qupaiSDKShowMoreMusicView:(id<ALBBQuPaiService>)sdk viewController:(UIViewController *)viewController;

@end

@interface ALBBQuPaiService : NSObject<ALBBQuPaiService>
+(instancetype)sharedService;
@property (nonatomic, weak) id<QupaiSDKDelegate> delegte;
@end
2
  • Did you resolve this? Thanks!
    – devjme
    Commented Aug 19, 2019 at 18:38
  • @devjme you can wrap the confused part in ObjC code, then expose a simpler API.
    – Lei Kan
    Commented Aug 20, 2019 at 6:41

1 Answer 1

0

Remember that all the obj-c protocol act as a abstract class I recommend to put "protocol, model and set base type as nsobject, another thing all the methods or properties maked as a "required" you need to specify it as Abstract.

[Protocol, Model]
[BaseType (typeof(NSObject))]
interface myAwesomeDelegate
{
  [Abstract]
  [Export(...)]
  void myRequiredMethod(uint param1)

  [Export(...)]
  void anotherMethod()
}

I recommend to use the objective sharpie tool it support .framework files using version 3.X with the command framework bind -f myFramework.framework for more info about it check https://developer.xamarin.com/guides/cross-platform/macios/binding/objective-sharpie/tools/ or also you can check in the xamarin Github bindings https://github.com/mono/monotouch-bindings, if you have any specific question about bindings please let me know

1
  • Thanks, but I have tried all these you said above. And my problem is sharpie confused abount ALBBQuPaiService, is a protocol and a interface. So I do not know how to manual change this.
    – Lei Kan
    Commented Apr 7, 2016 at 15:38

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.