最近做了一个ShareSDK IOS的接入 (ANE) , 现在想想其实很简单 不过由于对Xcode,ANE的不熟悉也折腾了好久, 舔着脸打扰客服好几天… 呵呵
目前把我接入的一些步骤列出来 希望能帮到你.
准备工作
0· Mac机器一台,最新的AIRSDK
1·下载你需要的SDK(定制下载,勾选你自己需要的分享平台)
2·下载https://github.com/ShareSDKPlatform/ANESample
编译libShareSDKForANE.a
运行ANESample-master/iOS/ShareSDKForANE/ShareSDKForANE.xcodeproj
1·将下载的ShareSDK拖入项目中
2·去除掉当前工程中所有的引用Lib库(全都清空)
3· 更改设备为ios Device
4· Command+B 编译项目
5· 修改ShareSDKForANE.m中用不到的Import及初始化
点击Command+B再次编译项目,此时Products下面的libShareSDKForANE.a应该变为黑色(如果有错误则为红色). 点击右侧的箭头找到对应的文件 Copy出来
注意,此时的libShareSDKForANE.a应该为200多KB 如果大小相差很多 请检查之前的步骤
编译ANE
1·将生成的libShareSDKForANE.a copy到 package/iphone-ARM 目录下
2·将下载的ShareSDK copy到package/iphone-ARM目录下
3·删除iphone-x86目录
4·修改ane.sh脚本为:
你的最新AIRSDK目录/adt -package -target ane ShareSDK.ane extension.xml -swc ShareSDKExtension.swc -platform iPhone-ARM -C ./iPhone-ARM . -platformoptions platformoptions.xml
5·修改platformoptions.xml (下面的XML对应 新浪微博,Qzone,微信,Facebook,Twitter)
<platform xmlns="http://ns.adobe.com/air/extension/16.0"> <description >ShareSDK Extension</description> <copyright>ShareSDK 2014 (optional)</copyright> <sdkVersion>7.0</sdkVersion> <linkerOptions> <option>-w</option> <option>-ios_version_min 5.11</option> <option>-framework Foundation</option> <option>-framework CoreTelephony</option> <option>-framework MessageUI</option> <option>-framework SystemConfiguration</option> <option>-framework QuartzCore</option> <option>-framework ImageIO</option> <option>-lz.1.2.5</option> <option>-licucore</option> <option>-lstdc++</option> <option>-lsqlite3</option> <option>-framework Security</option> </linkerOptions> <packagedDependencies> <packagedDependency>ShareSDK/Core/AGCommon.framework</packagedDependency> <packagedDependency>ShareSDK/Core/ShareSDKCoreService.framework</packagedDependency> <packagedDependency>ShareSDK/ShareSDK.framework</packagedDependency> <packagedDependency>ShareSDK/Connection/SinaWeiboConnection.framework</packagedDependency> <packagedDependency>ShareSDK/Connection/QZoneConnection.framework</packagedDependency> <packagedDependency>ShareSDK/Connection/WeChatConnection.framework</packagedDependency> <packagedDependency>ShareSDK/Connection/FacebookConnection.framework</packagedDependency> <packagedDependency>ShareSDK/Connection/TwitterConnection.framework</packagedDependency> <packagedDependency>ShareSDK/UI/ShareSDKiPadDefaultShareViewUI.framework</packagedDependency> <packagedDependency>ShareSDK/Extend/WeChatSDK/libWeChatSDK.a</packagedDependency> <packagedDependency>ShareSDK/Extend/SinaWeiboSDK/libWeiboSDK.a</packagedDependency> <packagedDependency>ShareSDK/Extend/QQConnectSDK/TencentOpenAPI.framework</packagedDependency> </packagedDependencies> </platform>
* 几点注意 这里很关键
- <platform xmlns="http://ns.adobe.com/air/extension/16.0”> 这里改为你AIRSDK对应的最新版本号 目前我是16.0
-· <option>-ios_version_min 5.11</option> 这里改为5.11
-· http://wiki.mob.com/快速集成指南/ 中说的新浪微博SDK依赖库 为ImageIO.framework 那么option中填写的方式为<option>-framework ImageIO</option>, 同理还包括libstdc++.dylib 对应的是 <option>-lstdc++</option> 请自行发现规律
-· <packagedDependency>ShareSDK/Extend/WeChatSDK/libWeChatSDK.a</packagedDependency> 在下载的ShareSDK中会有一些点a文件,这里也需要写进去
6· 修改extension.xml
<extension xmlns="http://ns.adobe.com/air/extension/16.0"> <id>cn.sharesdk.ane.ShareSDKExtension</id> <versionNumber>1</versionNumber> <platforms> <platform name="iPhone-ARM"> <applicationDeployment> <nativeLibrary>libShareSDKForANE.a</nativeLibrary> <initializer>ShareSDKInitializer</initializer> <finalizer>ShareSDKFinalizer</finalizer> </applicationDeployment> </platform> </platforms> </extension>
仅剩下 platform iPhone-ARM, 并且修改xmlns到16.0(当前最新的AIRSDK版本号)
7· CD到对应目录 sh ane.sh
如果一切顺利 则会产生ShareSDK.ane
测试ANE
我用的是Intellij,如果你用Flash Builder请自行根据步骤目的进行设置
1· 将下载的ShareSDK中的所有bundle文件 拖入项目,确保其最终被打包
2· 修改项目对应的xml配置文件,增加需要用到的URLSchemes
3· http://wiki.mob.com/社交平台配置项说明 中定于的需要传入参数初始化ShareSDK
一切顺利的话 你的ShareSDK应该已经可以工作了 :)
Enjoy
Best
Eran