频道
bg

ITMS-90809 Deprecated API Usage

coding十二月 29, 20211mins
IOS

iOS提交审核后,提示

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

意思是项目中使用被废弃的UIWebView。

解决H2

直接的办法升级项目依赖的版本,但是历史项目升级的成本比较高。另外一种方式删除所有引用了UIWebView的代码。这里主要讨论后者

首先使用下面的方式来查找,最终的分发包中是否引用了UIWebView

  1. 构建xcarchive归档包

  2. 找到归档包/Products/Application 目录下的elf文件的,执行

    bash

    nm xxx | grep UIWebView
  3. 如果包含UIWebView,则会返回类似下述的内容

    bash

    U *OBJC_CLASS*$_UIWebView

AppStore中是要求最终的二进制包文件中不能包含UIWebView的引用,单纯的使用useWebKit 等修改运行时的行为是没有用的,我们需要在构建时避免这些包的引用被编译进去。直接的方式是在xcode或者node_moudles 中搜索UIWebView ,然后把相关的文件删除。

bash

grep -r UIWebView node_modules/*
node_modules/fbjs/lib/UserAgent.js: * - UIWebView
node_modules/fbjs/lib/UserAgent.js.flow: * - UIWebView
node_modules/jsc-android/dist/include/JSContextPrivate.h:/*! @abstract The delegate the context will use when trying to load a module. Note, this delegate will be ignored for contexts returned by UIWebView. */
node_modules/metro/node_modules/fbjs/lib/UserAgent.js: * - UIWebView
node_modules/metro/node_modules/fbjs/lib/UserAgent.js.flow: * - UIWebView
node_modules/react-native/node_modules/fbjs/lib/UserAgent.js: * - UIWebView
node_modules/react-native/node_modules/fbjs/lib/UserAgent.js.flow: * - UIWebView
node_modules/react-native-webview/README.md:- [7.0.1](https://github.com/react-native-community/react-native-webview/releases/tag/v7.0.1) - Removed UIWebView
node_modules/ua-parser-js/test/browser-test.json: "ua" : "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Mobile/14A456 QQ/6.5.3.410 V1_IPH_SQ_6.5.3_1_APP_A Pixel/1080 Core/UIWebView NetType/WIFI Mem/26"

可能包括的地方有

  • React Native的RCTWebview
  • React Native WebView的RNCUIWebView
  • react-native-device-info的RNDeviceInfo

上面的方式只能查找源码中的引用,但是无法找到framework等二进制依赖文件。通过下面的脚本查找项目所有的framekwork文件,并查看它们的链接表

bash

FRAMEWORK_DIRS=$(find . -name '*.framework')
for framework in $FRAMEWORK_DIRS; do
fname=$(basename $framework .framework)
echo $framework/$fname
nm $framework/$fname | grep UIWeb
done

如果.framework 包含的静态链接文件,还有可能有.a的静态链接文件

可能包括的有

  • AlipaySDK
  • WeChatSDK

参考:

[1]: https://github.com/facebook/react-native/issues/26255

[2]: https://qiita.com/yum_fishing/items/95e7ff1528c6c69c00aa

评论


新的评论

匹配您的Gravatar头像

Joen Yu

@2022 JoenYu, all rights reserved. Made with love.