Unity 打包打包iOS 删除删除 UIWebView引用引用
介绍介绍
苹果在审核拒约时给出了以下信息:
ITMS-90809: Deprecated API Usage – Apple will stop accepting submissions of apps that use UIWebView APIs . See
https://developer.apple.com/documentation/uikit/uiwebview
for more information.
但是项目内并未使用 UIWebView API,尝试使用 Unity 构建一个空工程上传到 TestFlight 或者 QuickSDK
进行预先检查,发现依然存在 UIWebView API 调用。
搜索后发现 Unity 已在 2017.4, 2018.4, 2019.2, 2019.3, 2020.1 中修复,但是旧版本如 Unity 5.6 就不管了:
Unity Issue Tracker – [iOS] Apple throws Deprecated API Usage warning for using UIWebView when submitting Builds to
the App Store Connect
环境
Unity 2018.4.xf2
macOS 10.14.6
Xcode 11.0
解决方案解决方案
虽然 Unity 官方不准备在旧版本修复此 Bug,但是在问题描述中阐述了具体细节:在
PlatformDependent/iPhonePlayer/URLUtility.mm
中使用 UIWebView 处理游戏内链接。
搜索后找到了一个现成的解决方案,经过测试后可用:
libiPhone-lib.a去掉WebViewController – 简书
下面记录一下实践过程并补充一些相关信息。
保存源文件
首先将以下内容保存为 URLUtility.mm
#include
#import
using namespace std;
namespace core {
template
class StringStorageDefault {};
template
class basic_string {
public:
char *c_str(void);
};
}
void OpenURLInGame(core::basic_string< char,core::StringStorageDefault > const&arg){}
void OpenURL(core::basic_string<char,core::StringStorageDefault >const&arg){
const void *arg2= &arg;
UIApplication *app = [UIApplication sharedApplication];
NSString *urlStr = [NSString stringWithUTF8String:(char *)arg2];
NSURL *url = [NSURL URLWithString:urlStr];
[app openURL:url];
}
void OpenURL(std::string const&arg){
UIApplication *app = [UIApplication sharedApplication];
NSString *urlStr = [NSString stringWithUTF8String:arg.c_str()];
NSURL *url = [NSURL URLWithString:urlStr];
[app openURL:url];
}
评论0