Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么查哪个 SDK 使用了 UIWebView 的 API ? #25

Open
ChenYilong opened this issue May 3, 2020 · 2 comments
Open

怎么查哪个 SDK 使用了 UIWebView 的 API ? #25

ChenYilong opened this issue May 3, 2020 · 2 comments

Comments

@ChenYilong
Copy link
Owner

ChenYilong commented May 3, 2020

怎么查哪个 SDK 使用了 UIWebView 的 API ?


相信很多人都收到了 UIWebView 的 API 的警告邮件了,
Apple 正打算强制开发者弃用 UIWebView 的 API , 继续用可能会审核被拒.
自己是否用了该 API 只需要在 Xcode 中全局搜索即可, 那么如何查询自己的项目中哪个 sdk 使用了 UIWebView 的 API 呢?

以下步骤, 首先要进入到工程的根目录,然后使用终端输入如下命令:
这里介绍两种方式.

两种方式查 API 的方式

第一种

Grep

grep -r "UIWebView" .

打印效果:

输出结果为:

Binary file ./Alipay/AlipaySDK.framework/AlipaySDK matches
Binary file ./Alipay copy名称包含空格测试/AlipaySDK.framework/AlipaySDK matches
Binary file ./Alipaycopy/AlipaySDK.framework/AlipaySDK matches
Binary file ./Alipay名称包含汉语名称测试/AlipaySDK.framework/AlipaySDK matches
./shell.sh:  do if nm "$file"/`basename "$file"  | sed -e s/\\.framework$//g` 2>/dev/null  | grep UIWebView > /dev/null; then echo -e "[EN]"$file" contains API of UIWebView  \n[CN] "$file" 包含 UIWebView 相关 API "; fi;done
./WS_APP_PAY_SDK_BASE_15.7.5/iOS_Demo/AliSDKDemo/AliSDKDemo/APWebViewController.h:@interface APWebViewController : UIViewController<UIWebViewDelegate>
./WS_APP_PAY_SDK_BASE_15.7.5/iOS_Demo/AliSDKDemo/AliSDKDemo/APWebViewController.h:@property (strong, nonatomic) IBOutlet UIWebView *webView;
./WS_APP_PAY_SDK_BASE_15.7.5/iOS_Demo/AliSDKDemo/AliSDKDemo/APWebViewController.m:- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
./WS_APP_PAY_SDK_BASE_15.7.5/iOS_Demo/AliSDKDemo/AliSDKDemo/Base.lproj/Main.storyboard:                    <view key="view" contentMode="scaleToFill" id="NbF-BA-eFG" customClass="UIWebView">
./WS_APP_PAY_SDK_BASE_15.7.5/updatelog.txt:1. 去除UIWebView改为WKWebView

第二种

指定文件名

只查询 .framework .a 文件

echo "------------<🔎 search in *.framework & *.a & *.h & *.m & *.swift>-------------"
echo "------------------------<I>------------------------"
find . \( -name "*.framework" -o -name "*.a"  \) -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🇺🇸] Uncomment 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 "------------------------<I>------------------------";
echo "🎉 Done!";'

打印效果

查询 .framework .a .h .m .swift文件

echo "------------<🔎 search in *.framework & *.a & *.h & *.m & *.swift>-------------"
echo "------------------------<I>------------------------"
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🇺🇸] Uncomment 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 "------------------------<I>------------------------";
echo "🎉 Done!";'

打印效果:

注意上面修改文件类型,只需要修改第一行即可.

注意情况

有人检测出 Google SDK 包含了相关关键词,这是 Google 的回复:

Hi there
Thank you for reporting this
As mentioned by my colleague Deepika, grep -r “UIWebView" . does not necessarily mean that an SDK is calling UIWebview Some of the strings shown in the Google Mobile Ads SDK are part of log messages. Also, we’ve tested the latest version of the SDK and we didn’t get warnings about UIWebView usage
Could you double-check the other binaries in your app to verify whether they are using Webview? we also recommending our publishers to run multiple tests with a subset of their binaries (e. G. A test without any mediation adapter/SDKs binaries if you use mediation) to verify the offending binary.
Please let us know how it goes so I could raise this to the team once more.
Regards
Mobile Ads SDK Team

翻一下就是:

正如我的同事XXX提到的,grep -r "UIWebView " . 并不意味着SDK正在调用UIWebview。另外,我们测试了最新版本的SDK,没有收到关于UIWebView使用的警告。
我们也建议我们的发布者用他们的二进制文件的子集来运行多个测试(例如,如果你使用mediation的话,在没有任何mediation适配器/SDKS二进制文件的情况下进行测试),以验证违规的二进制文件。
请让我们知道情况如何,这样我可以再次向团队提出这个问题。
移动广告SDK团队

上面我提到的两种情况, 均与 Google 团队回复的情况一致, 上面的命令只是文本查找, 并不代表该文件一定使用了该API 谷歌的回复内容可以忽略,如果abi能找出来,就说明他编译到里面了,苹果的机审可不会管你有没有用。 请尽快与SDK提供商沟通,要求其提供升级版本, 避免被拒的风险.

相关代码可点击原文查看.

觉得有用的话,点击“在看”吧👇

@ChenYilong
Copy link
Owner Author


find . -type f | grep -e ".a" -e ".framework" | xargs grep -s UIWebView

@ChenYilong
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant