美文网首页
检查iOS项目中是否还有使用UIWebView

检查iOS项目中是否还有使用UIWebView

作者: 王家小雷 | 来源:发表于2020-10-09 18:28 被阅读0次

    主要方便查找静态库和动态库中使用到UIWebView的地方。

    • 方法一:
    cd 项目根目录
    find . -type f | grep -e ".a" -e ".framework" | xargs grep -s UIWebView
    
    
    • 方法二:
    1. 复制代码生成文件check.py。
    2. 将文件放置项目根目录,cd到该文件目录,执行python check.py。
    3. 注意:import subprocess是python3.0以上版本使用,否则用import commands。
    #!/usr/bin/python
    # -*-coding:utf-8 -*-
    
    import os
    import subprocess
    
    def check():
    
        for path, dir_list, file_list in os.walk('./'):
    
            for file_name in file_list:
    
                # 略过 .DS_Store 文件
                if file_name.find('.DS_Store') != -1:
                    continue
    
                # 略过 没有framework  .a 的文件
                #if path.find('.framework') == -1 and file_name.find('.a') == -1:
                    #continue
    
                full_path = os.path.join(path, file_name)
                # print(full_path)
    
                if full_path.endswith('.h'):
                    continue
    
                (status, output) = subprocess.getstatusoutput('file %s' % full_path)
                index = output.find('Mach-O universal binary')
                if index != -1:
                    # print(full_path)
    
                    (status, output) = subprocess.getstatusoutput('strings %s | grep -ir "uiwebview"' % full_path)
                    if len(output) > 0:
                        print (full_path)
    
    if __name__ == "__main__":
        print('Start to check library')
        check()
    
    

    </article>

    相关文章

      网友评论

          本文标题:检查iOS项目中是否还有使用UIWebView

          本文链接:https://www.haomeiwen.com/subject/mvxrpktx.html