iosxamarinxamarin.iosgoogle-signinobjective-sharpie

Google SignIn Xamarin Binding


I am trying to bind Google SignIn SDK 2.0 here

I have an issue with Delegate generated that represent a concrete class and not ISignInDelegate interface.

What is wrong in this ApiDefinition?

[BaseType (typeof (NSObject), Name = "GIDSignInDelegate")]
    [Protocol]
    [Model] 
    public interface SignInDelegate
    {
        // @required -(void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error;
        [Abstract]
        [Export ("signIn:didSignInForUser:withError:"), EventArgs ("SignInDelegateDidSignInForUser")]
        void DidSignInForUser (SignIn signIn, GoogleUser user, NSError error);

        // @optional -(void)signIn:(GIDSignIn *)signIn didDisconnectWithUser:(GIDGoogleUser *)user withError:(NSError *)error;
        [Export ("signIn:didDisconnectWithUser:withError:"), EventArgs ("SignInDelegateDidDisconnect")]
        void DidDisconnect (SignIn signIn, GoogleUser user, NSError error);
    }

Solution

  • What you're showing is fine, but partial incomplete. You're asking for both a protocol (interface) and a model (a concrete) type to be generated. That's fine but the name is for the model (and the protocol is generated with an I prefix).

    From your link I see that your delegate property was generated with SignInDelegate as it's type, e.g.

    public SignInDelegate Delegate {
    

    and that's the model (concrete) type, likely because it's how you created the bindings (to the model, not the protocol). If that's the case then simply add

    interface ISignInDelegate {}
    

    in your binding file (e.g. just above the bindings for SignInDelegate) and use this type for the delegate property, e.g.

    public ISignInDelegate Delegate { ... }
    

    IOW you're just providing (earlier) what the generator will produce and that let you use the interface (for the protocol) while writing the bindings.