inline __attribute__((always_inline))
static void check_cm(Class cls, SEL method, int bClassMethod) {
IMP __code__IMP;
Dl_info __code__info;
Method __code__meth = bClassMethod ? class_getClassMethod(cls, method) : class_getInstanceMethod(cls, method);
__code__IMP = method_getImplementation(__code__meth);
dladdr((const void *)__code__IMP, &__code__info);
NSLog(@"1:%s", __code__info.dli_sname);
NSLog(@"2:%s", __code__info.dli_fname);
}
@implementation TestViewController
+ (void)load {
check_cm([TestViewController class], @selector(AFuncation), 0);
check_cm([TestViewController class], @selector(BFuncation), 0);
check_cm([TestViewController class], @selector(CFuncation), 0);
}
void registerFuncation() {}
- (void)AFuncation {}
- (void)BFuncation {}
- (void)CFuncation {
registerFuncation();
}
@end
上诉这段代码,App进程与VPN进程共用。
通过Xcode Archive编译,两个进程运行的结果都正确。
通过xcodebuild archive 命令来编译的,App进程运行结果正确,VPN进程打印结果sname变成registerFuncation。
这是为什么?