iOS检查项目中是否存在废弃的UIWebView

背景

苹果2020年12月将不再接受使用UIWebView,相反,使用WKWebView来提高安全性和可靠性,老项目的具体问题邮件:

Dear Developer,
We identified one or more issues with a recent delivery for your app, "老项目" 2.42.1 (2.42.15). Your delivery was successful, but you may wish to correct the following issues in your next delivery:
ITMS-90809: Deprecated API Usage - App updates that use UIWebView will no longer be accepted as of December 2020. Instead, use WKWebView for improved security and reliability. Learn more (https://developer.apple.com/documentation/uikit/uiwebview)).
After you’ve corrected the issues, you can upload a new binary to App Store Connect.
Best regards,
The App Store Team

新项目的提交必须全部移除UIWebView,要不然机审都过不了,新项目的具体问题邮件:

Dear Developer,
We identified one or more issues with a recent delivery for your app, "新项目" 1.0.0 (1.0.1). Please correct the following issues, then upload again.
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)).
Best regards,
The App Store Team

方法

1、终端命令Grep

//终端命令
grep -r "UIWebView" .

会筛查并列出当前文件下的所有包含UIWebView的字段,包括注释里面的。注意不要漏掉后面的"."

2、指定要检测的文件类型

//终端命令,查询 .framework .a .h .m .swift文件
echo "------------< search in *.framework & *.a & *.h & *.m & *.swift>-------------"
echo "------------------------------------------------"
find . \( -name "*.framework" -o -name "*.a"  -o -name "*.h"  -o -name "*.m" -o -name "*.swift" \) -exec sh -c ' 
usefullArray=();
uselessArray=();
for file do
if  nm "$file"/`basename "$file"  | sed -e s/\\.framework$//g` 2>/dev/null  | grep -rl UIWebView > /dev/null  ; then
usefullArray+=("$file")
elif grep -rl "UIWebView" "$file" > /dev/null;  then
usefullArray+=("$file")
elif   nm "$file" 2>/dev/null  | grep -rl UIWebView > /dev/null; then
usefullArray+=("$file")
#[EN] open this line for more log information[CN]打开本行注释可以看到扫描日志
#else uselessArray+=("$file")
fi
done
for i in "${uselessArray[@]}"
do
echo "✅  UIWebView does not appear  in "$file"";
done
for i in "${usefullArray[@]}"
do
echo "⚠️   UIWebView          appears in "$i"";
done
' sh {} + ;
sh -c 'echo "------------------------------------------------";
echo " Done!";'

注意:如果上面的筛查没有查出,多试几次,我当时第一次就没筛查出来,多试了几次才好

截图:被苹果支配的恐惧

一直过不了机审
最终成功

参考资料:https://github.com/ChenYilong/iOSBlog/issues/25

你可能感兴趣的:(iOS检查项目中是否存在废弃的UIWebView)