Problems encountered
After the document Access project that came with the Sina Weibo SDK, the project runs on the real machine and crashes when the registration method is invoked. Registration Method Code:
1 |
[WeiboSDK registerApp: @"xxxxxxxx"];
|
The crash information is printed as follows:
1 |
[__NSDictionaryM weibosdk_WBSDKJSONString] : unrecognized selector sent to instance 0x170255780
|
Resolve problems encountered by the obstacles
There is a note in the documentation included with the Sina Weibo SDK:
After a static library is introduced into the project, you need to add the –OBJC compilation option at compile time to avoid a program crash due to incomplete class loading in the static library. Method: Program Target->buid settings->linking under other Linker Flags item added-OBJC
People who have encountered the same crash on the web have mentioned that adding compilation options at compile time -all_load
can also solve the problem. The method is also added under Target->buid settings->linking other Linker Flags item -all_load
. The same crash occurs when the compilation runs again.
Both the set- -ObjC
up -all_load
and compile-time failures will report link errors that cannot be found for the symbol above.
The right solution
Here's the right solution to talk about why. The correct approach is to set the other Linker Flags this compile option, -ObjC
but is -all_load
not used and can not be used, but to use -force_load path/to/your/libWeiboSDK.a
, followed by the Sina Weibo SDK static link library of the exact location.
Why is all this?
It is said to have links, loads and libraries, so be prepared to read the "self-cultivation of programmers".
IOS platform Project access to Sina Weibo SDK pit