Unity导出Xcode工程ShareSDK功能的配置
前言:ShareSDK在IOS设备上分享还需要在Xcode中进行相应的配置,否则IOS设备分享有可能会分享不成功
1:Unity导出Xcode工程后,拷贝到Mac电脑,并用Xcode打开,导入ShareSDK for IOS
2:添加依赖库
必须添加的依赖库如下:
SystemConfiguration.framework
QuartzCore.framework
CoreTelephony.framework
libicucore.dylib
libz.1.2.5.dylib
Security.framework
以下依赖库根据社交平台添加
新浪微博SDK依赖库 (从v2.10.5开始)
ImageIO.framework
腾讯微博SDK依赖库(腾讯打算关闭此接口,所以不推荐使用)
Social.framework
Accounts.framework
短信和邮件分享必要
MessageUI.framework
QQ好友和QQ空间SSO必要(新注册腾讯开放平台帐号只支持SSO授权,只是老开发者才可以使用网页授权)
libstdc++.dylib
libsqlite3.dylib
Google+ 分享必要
CoreMotion.framework
CoreLocation.framework
MediaPlayer.framework
CoreText.framework
AssetsLibrary.framework
AddressBook.framework
2015.10.26日更新:
必须添加的依赖库如下:
- SystemConfiguration.framework
- QuartzCore.framework
- CoreTelephony.framework
- libicucore.dylib
- libz.1.2.5.dylib
- Security.framework
- JavaScriptCore.framework
- libstdc++.dylib
- CoreText.framework
以下依赖库根据社交平台添加
1.新浪微博SDK依赖库
- ImageIO.framework
- AdSupport.framework
- libsqlite3.dylib
2.腾讯微博SDK依赖库
- Social.framework
- Accounts.framework
3.短信和邮件分享必要
- MessageUI.framework
4.QQ好友和QQ空间SSO必要(新注册腾讯开放平台帐号只支持SSO授权,只是老开发者才可以使用网页授权)
- libsqlite3.dylib
5.微信分享必要(从2.11.2开始)
- libsqlite3.dylib
6.Google+ 分享必要
- CoreMotion.framework
- CoreLocation.framework
- MediaPlayer.framework
- AssetsLibrary.framework
- AddressBook.framework
错误提示
:You must rebuild it with bitcode enabled (Xcodesetting ENABLE_BITCODE)
未来Watch应用须包含Bitcode,iOS不强制,但Xcode7默认会开启Bitcode。
如何适配?
方法一:更新library使包含Bitcode,否则会出现以下中的警告;
1
|
(
null
): URGENT: all bitcode will be dropped because
‘/Users/myname/Library/Mobile Documents/com~apple~CloudDocs/foldername/appname/GoogleMobileAds.framework/GoogleMobileAds(GADSlot+AdEvents.o)‘
was built without bitcode. You must rebuild it
with
bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode
for
this
target. Note: This will be an error
in
the future.
|
方法二:关闭Bitcode
工程设置中 buildingsetting 中搜索bitcode 选择no
3:设置unityappcontroller.mm文件
打开unityappcontroller.mm文件。
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL*)url
{
return [ShareSDK handleOpenURL:url wxDelegate:nil];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:nil];
}
加入头文件sharesdk/sharesdk.h,将以下代码添加到文件中。
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL*)url
{
return [ShareSDK handleOpenURL:url wxDelegate:nil];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:nil];
}
并注释掉原先重复的代码,否则报错
4:设置Info
在info处,添加url。分别填写程序包名、在微信平台申请的appkey。如图:
详细请看官网例子:点击打开链接
交流探讨,可以加我QQ:503115254
转载请注明出处。