天天看點

開發騰訊移動遊戲平台SDK ios版Ane擴充 總結

本文記錄了在開發 騰訊移動遊戲平台SDK(MSDK) ios版Ane擴充 過程中所遇到的問題

文中很多問題都是基礎的問題、對object c和xcode配置了解不深入導緻的。(沒辦法,開發ane的程式員大部分都是做ActionScript的,一般對c/c++都沒有開發經驗)

問題一、編譯報錯:Unexpected ‘@’ in program

代碼如下:

@try{

}

@catch{

原因是高版本xcode代碼放在低版本xcode下跑,低版本ios 不支援這種寫法(ios 7.0編譯正常),需要修改設定ios Deployment Target屬性

如果要支援安裝在低版本的ios上,則不能用這種寫法----待确認??

問題二、c++代碼和object-c混合編譯,會報錯:Cannot use ‘@try‘ with Objective-C exceptionsdisabled

解決辦法:修改target -> build settings -> All | Combined -> Apple LLVMCompiler 5.0 - Language - Objective C 中 EnableObjective-C Exceptions 為YES

問題三、編譯報錯 instance method ‘-AddList:‘ not found (returntype defaults to ‘id‘)

原因1:沒有import .h檔案,隻通過 @class file 方式引用了檔案,解決方法是 把檔案import進來

原因2:執行個體方法和靜态方法搞錯了

問題四、項目移植到另一個版本ide後編譯報錯

Unsupported compiler ‘com.apple.compilers.llvmgcc42‘ selected forarchitecture ‘armv7‘

Unableto determine concrete GCC compiler for file/Users/flash8/Desktop/app/TencentMSDKAneIOS/TencentMSDKAneIOS/TencentMSDKAneIOS.mof type sourcecode.c.objc.

原因是xcode版本不同,編譯器不一樣了,解決方法:

設定 Build Settings-> Build Options -> Compiler for C/C++/Objective-C 選擇DefaultComplier (Apple LLVM 5.1)

問題五、打包時報錯:ld: framework not found AdSupport

原因是platformoptions.xml中未添加在上添加AdSupportframework,注意(低于IOS 6.0系統需要在xcode中設定為Optional)

<option>-frameworkAdSupport</option>

問題六、打包時報錯:-[GDataXMLElement attributeForName]......一大段

原因是platformoptions.xml中未添加在上添加libxml2

<option>-lxml2</option>

問題七、打包時報錯:

Undefined symbols for architecture armv7:  

 "_TencentMSDKAneIOSExtInitializer",referenced from:

     _g_com_adobe_air_fre_fmap in extensionglue.o

     (maybe you meant:_TencentMSDKAneIOSExtInitializer_name)

     (maybe you meant:_TencentMSDKAneIOSExtFinalizer_name)

 ld:symbol(s) not found for architecture armv7

Compilationfailed while executing : ld64

找了好久,一直懷疑是類庫漏了或配置錯誤,後來發現原因是 c++把函數名翻譯了(這個項目包含c++代碼)

解決辦法是在頭檔案中用extern c把那兩入口函數包住

#if__cplusplus

extern"C" {

#endif

void *TencentMSDKAneIOSExtInitializer();

}  // Extern C

參考連結:http://stackoverflow.com/questions/7376003/linker-error-using-extern-c-in-objective-c-code

【原文連結: 

轉載請注明出處】