_bridgeToObjectiveC 怎么hook

Swift的方法如下:

func bridge_swift_test1(_ data: [UInt8]) -> [UInt8]? {
         print("bridge_swift_test1:", data)
         return [3, 4]
     }

hook是没问题的,但是参数打印的时候就出错了:

// _$sSa10FoundationE19_bridgeToObjectiveCSo    7NSArrayCyF:        // (extension in Foundation):Swift.Array._bridgeToObjectiveC() -> __C.NSArray
    static NSArray* (*orig_swift_array_to_nsarray_function)(id _self) = NULL;

typedef NSArray* SwiftReturnType;

static SwiftReturnType (*orig_swift_test1_function)(SwiftReturnType) = NULL;
static SwiftReturnType hook_swift_test1_function(SwiftReturnType arg0, id _self) {
    NSLog(@"Hooked SwiftFunction");
    SwiftReturnType r = orig_swift_test1_function(arg0);
    // 打印会crash
//    NSLog(@"%@", r);
    // 调用方法也会crash
    id tmp = orig_swift_array_to_nsarray_function(arg0);
    return r;
}

我看到原生的调用方法是调用_bridgeToObjectiveC,汇编看得不大懂,大佬们可以指导一下吗

SwiftReturnType r = orig_swift_test1_function(arg0);
你调用原方法不传 self 参数吗

函数指针声明参数至少一样啊

SwiftReturnType (*orig_swift_test1_function)(SwiftReturnType arg0, id _self)

声明一样之后还是出错了,我看到这样定义之后_self是nil