1
votes

Trying to fix issues with FBSDKEventBindingManager.m error for few days but still having hard time to find solution.

Error:

Incompatible block pointer types sending 'void (^__strong)(__strong id)' to parameter of type 'swizzleBlock' (aka 'void (^)(void)')

Error in this line => withBlock:blockToSuperview named:@"map_control"];

void (^blockToSuperview)(id view) = ^(id view) {
    [self matchView:view delegate:nil];
};

void (^blockToWindow)(id view) = ^(id view) {
    [self matchView:view delegate:nil];
};


[FBSDKSwizzler swizzleSelector:@selector(didMoveToSuperview) 
                       onClass:[UIControl class]
                     withBlock:blockToSuperview named:@"map_control"];

[FBSDKSwizzler swizzleSelector:@selector(didMoveToWindow)
                       onClass:[UIControl class]
                     withBlock:blockToWindow named:@"map_control"];
1
add code what you have for blockToSuperview and blockToSuperview to better understand it. - Bhavin Kansagara
Hi Bhavin, here's the reference from line 126 to line 140: github.com/facebook/facebook-ios-sdk/blob/master/FBSDKCoreKit/… - Lichard Baliuag
Hi Bhavin, just updated the reference for blockToSuperview, hope this will help. Really struggling this past few days. Appreciate any help, thank you. - Lichard Baliuag
You've probably got a mismatch either in nullability or in the ARC strong/weak/unretained specifiers between your blocks and the ones specified by the SDK. Try explicitly typing the blocks as swizzleBlock by doing something like: swizzleBlock blockToSuperview = ^(id view) { ... }. - Charles Srstka
@LichardBaliuag checkout my answer, that is what I understood from the reference you have provided. - Bhavin Kansagara

1 Answers

0
votes

The problem is where FBSDK using typedef for swizzleBlock

typedef void (^swizzleBlock)();

This can be explained like

typedef void (^swizzleBlock)(void); //void (^)(void) format

Line 24 here:

And the parameter being passed is of type

void (^blockToSuperview)(id view) = ^(id view) // void (^__strong)(__strong id)'

Which leads to type mismatch and showing you error

Incompatible block pointer types sending 'void (^__strong)(__strong id)' to parameter of type 'swizzleBlock' (aka 'void (^)(void)')

Refer this, it will helps you to understand the Objective-C block syntax at various points.

You should update the typedef to match the passing block.

typedef void (^swizzleBlock)(id);

Fixing, this will fix the error at a point, but in the same file there are many other types of block with different format, e.g tableViewBlock(line 185), collectionViewBlock(line 200) checkout here. so, you will have to look for some generic workaround to fix it.

Hope it helps.