链接到 CoreTelephony 框架 (iOS)
有谁知道为什么当我尝试编译以下代码时出现链接器错误:
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
make 输出为:
架构armv6的未定义符号: “CTServerConnectionCreate(_CFAllocator const*, int ()(void, __CFString const*, __CFDictionary const*, void*), int*)”,引用自: Tweak.xm.o 中的 $_ungrouped$UIKeyboard$hitTest$withEvent$(UIKeyboard*, objc_selector*, CGPoint, objc_object*) ld:找不到架构armv6的符号 collect2:ld返回1退出状态
一些注意:
- 我使用-framework CoreTelephony链接到CoreTelephony
- 我使用这里的代码核心电话示例
- 我在 iOS 4.x 和 iOS 5.x 上尝试过
- ,我使用 nm 来确保函数调用位于二进制文件内
,是的,我在越狱设备上。
谢谢 ;)
Does anyone know why I get a linker error when I try to compile the following code:
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
make output is:
Undefined symbols for architecture armv6:
"CTServerConnectionCreate(_CFAllocator const*, int ()(void, __CFString const*, __CFDictionary const*, void*), int*)", referenced from:
$_ungrouped$UIKeyboard$hitTest$withEvent$(UIKeyboard*, objc_selector*, CGPoint, objc_object*) in Tweak.xm.o
ld: symbol(s) not found for architecture armv6
collect2: ld returned 1 exit status
Some NOTES:
- I link against CoreTelephony with -framework CoreTelephony
- I use the code from here Core Telephony Example
- I tried it on both iOS 4.x and iOS 5.x
- I used nm to ensure that the function call is inside the binary
And yes I'm on a jailbroken device.
Thanks ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需在 XCode 中包含 CoreTelephony.framework 即可。应该有效!
Just include CoreTelephony.framework in XCode. Should work!
您可能想要声明不带下划线的私有函数。
编译器会自动添加下划线前缀。
You might want to declare your private function without the underscore.
The compiler will automatically add the underscore prefix.