注册

iOS上架unity工程包含UIWebView问题

在经过一系列的开发之后,来到了游戏上架的步骤,但是在上架的过程中,收到了被拒邮件

ITMS-90809: Deprecated API Usage - New apps that use UIWebView are no longer accepted. 
Instead, use WKWebView for improved security and reliability.
Learn more (https://developer.apple.com/documentation/uikit/uiwebview).

Though you are not required to fix the following issues,
we wanted to make you aware of them:

收到这个邮件之后,我首先全局搜索了我的工程中,是否包含UIWebView,但是并没有找到对应的文件。此时,就需要通过命令行来搜索自己的工程中,到底哪些地方包含UIWebView

1、首先确定包含UIWebView的地方,在命令行中cd到你的工程文件夹下,输入以下命令:

grep -r UIWebView .

be4771f03c2a910e888c7c5bf2693bb7.png

da19b1b2fbeb760f3500df034abc72e4.png

2、确定包含的UIWebView之后,我们需要处理掉lib.a中的UIWebView

由于这个是包含在游戏的lib.a的静态库里边,所以,我们要对这个库进行处理,可以通过Git上的自动脚本来处理:

处理lib.a静态库中的UIWebView

3、或者也可以自己手动处理(建议使用脚本)

1.新建URLUtility.mm文件,放在桌面
复制以下代码

#include <iostream>
#import <UIKit/UIKit.h>

using namespace std;

namespace core {
template <class type>
class StringStorageDefault {};
template <class type,class type2>
class basic_string {
public:
char *c_str(void);
};
}

void OpenURLInGame(core::basic_string< char,core::StringStorageDefault<char> > const&arg){}

void OpenURL(core::basic_string<char,core::StringStorageDefault<char> >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];

}

2.查看Unity项目下libiPhone-lib.a架构

lipo -info libiPhone-lib.a

结果如下:
Architectures in the fat file:
/Users/xxx/Desktop/libiPhone-lib.a are: arm64 armv7
则该静态库包含两种框架

生成URLUtility.mm armv7架构对应的URLUtility.o

clang -c URLUtility.mm -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk

新建armv7文件夹,将生成的URLUtility.o放入该文件夹, 后面会用到
生成URLUtility.mm arm64架构对应的URLUtility.o

clang -c URLUtility.mm -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk

新建arm64文件夹,将新生成的URLUtility.o放入该文件夹,后面会用到

如果有更多架构只需要把armv7替换成对应的架构分别生成

拆分libiPhone-lib.a
该命令是拆分libiPhone-lib.a中armv7架构部分
输出到/Users/xxx/Desktop/armv7/libiPhone-armv7.a
拆分成armv7架构

lipo libiPhone-lib.a -thin armv7 -output /Users/xxx/Desktop/armv7/libiPhone-armv7.a

拆分成arm64架构

lipo libiPhone-lib.a -thin arm64 -output /Users/xxx/Desktop/arm64/libiPhone-arm64.a

替换libiPhone-lib.a中的URLUtility.o
将各自架构libiPhone-lib.a里的URLUtility.o替换为我们生成的

ar -d 是移除
ar -q是添加
移除并且替换armv7中的URLUtility.o
ar -d /Users/xxx/Desktop/armv7/libiPhone-armv7.a URLUtility.o
ar -q /Users/xxx/Desktop/armv7/libiPhone-armv7.a /Users/xxx/Desktop/armv7/URLUtility.o

移除并且替换arm64

ar -d /Users/xxx/Desktop/arm64/libiPhone-arm64.a URLUtility.o
ar -q /Users/xxx/Desktop/arm64/libiPhone-arm64.a /Users/xxx/Desktop/arm64/URLUtility.o

合并libiPhone-lib.a

该命令的意思是将libiPhone-arm64.a libiPhone-armv7.a合并成桌面上的libiPhone-lib2.a
lipo -create /Users/xxx/Desktop/arm64/libiPhone-arm64.a /Users/xxx/Desktop/armv7/libiPhone-armv7.a -output /Users/xxx/Desktop/libiPhone-lib2.a

然后将libiPhone-lib2.a替换进Unity项目中即可使用

3、替换之后,重新运行,打包工程,提交上架即可

0 个评论

要回复文章请先登录注册