2011-09-05 82 views
1

有谁知道为什么我得到一个链接错误,当我尝试编译下面的代码:链接对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 

使输出为:

为未定义的符号架构armv6: “CTServerConnectionCreate( _CFAllocator const *,int()(void,__CFString const *,__CFDictionary const *,void *),int *)”,reference, d从: $ _ungrouped $ UIKeyboard $ hitTest $ withEvent $(UIKeyboard *,objc_selector *,CGPoint,objc_object *)in Tweak.xm.o ld:symbol(s)not for架构armv6 collect2:ld返回1出口状态

一些注意事项:

  • 我对CoreTelephony链接与-framework CoreTelephony
  • 我使用的代码从这里Core Telephony Example
  • 我试图在两者的iOS 4.x和5.x的iOS版
  • 我用纳米,确保函数调用内部的二元

是的我是一个越狱的设备上。

谢谢;)

回答

0

只需在XCode中包含CoreTelephony.framework。应该管用!

0

你可能想声明你的私有函数没有下划线。

extern void *CTServerConnectionCreate(); 

// Call 
myRes = CTServerConnectionCreate(args); 

编译器会自动添加下划线前缀。