一、微信注册失败
微信注册[WeiboSDK registerApp: @"xxxxxxxx"]该放在哪?
放在AppController的didFinishLaunchingWithOptions里会出现类似错误:
[__NSDictionaryM weibosdk_WBSDKJSONString] : unrecognized selector sent to instance 0x170255780
二、解决问题遇到的阻碍
网上解决办法一:
在工程中引入静态库之后,需要在编译时添加 –ObjC 编译选项,避免静态库中类 加载 不全造成程序崩溃。方法:程序 Target->Buid Settings->Linking 下 Other Linker Flags 项添加-ObjC
网上解决办法二:
在编译时添加
-all_load
编译选项时也可以解决问题。方法也是在 Target->Buid Settings->Linking 下 Other Linker Flags 项添加
-all_load
。
微信Demo里是-Objc和-all_load,但我的cocos2d-x 项目如上添加之后会出现以下错误:
Undefined symbols for architecture i386:
"_GCControllerDidConnectNotification", referenced from:
-[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)
"_GCControllerDidDisconnectNotification", referenced from:
-[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)
"_OBJC_CLASS_$_GCController", referenced from:
objc-class-ref in libcocos2dx iOS.a(CCController-iOS.o)
(maybe you meant: _OBJC_CLASS_$_GCControllerConnectionEventHandler)
三、
正确的解决办法
这里先给出正确的解决办法再谈谈为什么要这么做。正确的做法还是设置 Other Linker Flags 这个编译选项,只不过即不用用也不能用-ObjC
,而是要用-all_load
-force_load path/to/your/libWeiboSDK.a
,后面跟的是新浪微博 SDK 静态链接库的确切位置。
四、原因
链接地址:http://blog.csdn.net/yqmfly/article/details/45148081