2011-09-05 107 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); 

編譯器會自動添加下劃線前綴。