Search code examples
iosobjective-cswiftxcode11

How to fix the incompatible block pointer types sending error?


The Build fails because of the incompatible block pointer types sending error in xcode 11.5.

- (NSURLSessionDataTask *)retrieveSourceWithId:(NSString *)identifier 
    clientSecret:(NSString *)secret 
    responseCompletion:(STPAPIResponseBlock)completion {
    NSString *endpoint = [NSString stringWithFormat:@"%@/%@", 
        APIEndpointSources, identifier];
    NSDictionary *parameters = @{@"client_secret": secret};
    return [STPAPIRequest<STPSource *> getWithAPIClient:self

                                           endpoint:endpoint

                                         parameters:parameters

                                       deserializer:[STPSource new]

                                         completion:completion];

}

enter image description here


Solution

  • Observe the difference between two types of the block as described in the error.

    You are sending

    STPAPIResponseBlock aka ^(ResponseType, NSHTTPURLResponse, NSError)

    Expected type is:

    ^(STPSource, NSHTTPURLResponse, NSError)

    The first parameter of STPAPIResponseBlock isn't compatible.

    However it appears that this might be a bug in the Stripe API

    Confirm you have 14.0.1 or higher of the library. That might fix the issue.