当我尝试编译以下代码时,有谁知道为什么会出现链接器错误:
extern void * _CTServerConnectionCreate(CFAllocatorRef, int (*)(void *, CFStringRef, CFDictionaryRef, void *), int *);
int callback(void *connection, CFStringRef string, CFDictionaryRef dictionary, void *data)
{
return 0;
}
%hook UIKeyboard
-(id)hitTest:(CGPoint)test withEvent:(id)event
{
int x = 0;
_CTServerConnectionCreate(kCFAllocatorDefault, callback, &x);
return %orig;
}
%end
使输出为:
架构 armv6 的未定义符号:“ CTServerConnectionCreate( _CFAllocator const*, int ( )(void , __CFString const*, __CFDictionary const*, void*), int*)”,引用自:$_ungrouped$UIKeyboard$hitTest$withEvent$(UIKeyboard *, objc_selector*, CGPoint, objc_object*) 在 Tweak.xm.o ld: 未找到架构 armv6 collect2 的符号: ld 返回 1 个退出状态
一些注意事项:
- 我使用-framework CoreTelephony 链接 CoreTelephony
- 我使用这里的代码Core Telephony Example
- 我在 iOS 4.x 和 iOS 5.x 上都试过了
- 我使用nm来确保函数调用在二进制文件中
是的,我在越狱设备上。
谢谢 ;)