检查库文件中是否有使用了uiwebview类

可以检查静态库中是否带有 uiwebview 的字符串,以解决苹果要求的去掉 uiwebview 的需求。

前提:

1. 只能用于静态库。动态库需要改下。

2. 没有检查源代码文件。

 1 #!/usr/bin/python
 2 # -*-coding:utf-8 -*-
 3 
 4 import os
 5 import commands
 6 
 7 def main():
 8 
 9     for path, dir_list, file_list in os.walk('./'):
10 
11         for file_name in file_list:
12 
13             # 略过 .DS_Store 文件
14             if file_name.find('.DS_Store') != -1:
15                 continue
16 
17             # 略过 没有framework  .a 的文件
18             if path.find('.framework') == -1 and file_name.find('.a') == -1:
19                 continue
20 
21             full_path = os.path.join(path, file_name)
22             # print(full_path)
23 
24             if full_path.endswith('.h'):
25                 continue
26 
27             (status, output) = commands.getstatusoutput('file %s' % full_path)
28             index = output.find('Mach-O universal binary')
29             if index != -1:
30                 # print(full_path)
31 
32                 (status, output) = commands.getstatusoutput('strings %s | grep -ir "uiwebview"' % full_path)
33                 if len(output) > 0:
34                     print full_path
35 
36 
37 
38 if __name__ == "__main__":
39     print('Start to check library')
40     main()

猜你喜欢

转载自www.cnblogs.com/huangzizhu/p/12202330.html