开发腾讯移动游戏平台SDK ios版Ane扩展 总结

 来源:http://blog.csdn.net/linguifa/article/details/25741807ios

本文记录了在开发 腾讯移动游戏平台SDK(MSDK) ios版Ane扩展 过程当中所遇到的问题c++

文中不少问题都是基础的问题、对object c和xcode配置了解不深刻致使的。(没办法,开发ane的程序员大部分都是作ActionScript的,通常对c/c++都没有开发经验)程序员

 

问题1、编译报错:Unexpected ‘@’ in programobjective-c

代码以下:
@try{
}
@catch{
}
缘由是高版本xcode代码放在低版本xcode下跑,低版本ios 不支持这种写法(ios 7.0编译正常),须要修改设置ios Deployment Target属性
若是要支持安装在低版本的ios上,则不能用这种写法----待确认??xcode

 

问题2、c++代码和object-c混合编译,会报错:Cannot use '@try' with Objective-C exceptionsdisabledapp

解决办法:修改target -> build settings -> All | Combined -> Apple LLVMCompiler 5.0 - Language - Objective C 中 EnableObjective-C Exceptions 为YESide

 

问题3、编译报错 instance method '-AddList:' not found (returntype defaults to 'id')函数

缘由1:没有import .h文件,只经过 @class file 方式引用了文件,解决方法是 把文件import进来
http://blog.csdn.net/liuyuyefz/article/details/8189210ui

缘由2:实例方法和静态方法搞错了.net

 

问题4、项目移植到另外一个版本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)

 

问题5、打包时报错:ld: framework not found AdSupport

缘由是platformoptions.xml中未添加在上添加AdSupportframework,注意(低于IOS 6.0系统须要在xcode中设置为Optional)
<option>-frameworkAdSupport</option>

 

问题6、打包时报错:-[GDataXMLElement attributeForName]......一大段

缘由是platformoptions.xml中未添加在上添加libxml2
<option>-lxml2</option>

 

问题7、打包时报错:

Undefined symbols for architecture armv7:  
 "_TencentMSDKAneIOSExtInitializer",referenced from:
     _g_com_adobe_air_fre_fmap in extensionglue.o
     (maybe you meant:_TencentMSDKAneIOSExtInitializer_name)
 "_TencentMSDKAneIOSExtInitializer",referenced from:
     _g_com_adobe_air_fre_fmap in extensionglue.o
     (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();
void *TencentMSDKAneIOSExtInitializer();
#if__cplusplus
}  // Extern C
#endif
参考连接:http://stackoverflow.com/questions/7376003/linker-error-using-extern-c-in-objective-c-code


问题八、#import<vector> 编译时提示错误“vector.h file not found”

缘由是项目中引入了C++ STL里的vector.h文件,编译器的配置不对,修改以下配置便可:1. 选择project -> build setting -> apple LLVM compiler 3.0 – language配置项,2. 将Compile Sources As设置项修改成Objective-C++。

相关文章
相关标签/搜索