BDAnalyze 1.3.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05d38d8450cd4b4045fa1cfc87dca585e291f0a1
4
- data.tar.gz: c02d997ff4466166d6c044f7f1e3b9bd20fb75d3
3
+ metadata.gz: 28b57ff70ff6cf20d330ac572e7978bf01762045
4
+ data.tar.gz: ebca3d7258e2ba67460b4b26cb9ca5e9a5f0de68
5
5
  SHA512:
6
- metadata.gz: d9d00d17ae5bfdfda9a8d0f2e48a47de7b5d10f9c87c0a078effaef2457d0a0afe57c567343015360d48f270d00846fed24a852edfbf6507f2b463bdcae26b8d
7
- data.tar.gz: 154fe571fd46edde09ceadb20b99138e2c52766bc984ab2172e211075951089ced2ec55cec6362be4a6111d52d2e18fa3ebac5d389e43e2e9cbdb34503f887ca
6
+ metadata.gz: d616baa1171ff94d1e31fcc13db6710dd132b102c416d90fb2ea4a7161221a0635a210fd1856d0cc91ec3b7aebce2b2e78cc2a4a52e5e6d5c17d4524540da66f
7
+ data.tar.gz: '087b0660d823e6be1ccb08c0b718dfa599d04699a0e6a0aca49634c6014ff54ae582f996fa7808984b11bbd7ec5c40160c8f45e8dc20a083e8c4f2868c0394e9'
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
- # BDAnalyze
2
1
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/BDAnalyze`. To experiment with that code, run `bin/console` for an interactive prompt.
2
+ # BDAnalyze
4
3
 
5
- TODO: Delete this and the text above, and describe your gem
4
+ BDAnalyze是一款用于下沉iOS代码,分析iOS代码以及Pods组件之间依赖的工具
6
5
 
7
6
  ## Installation
8
7
 
@@ -22,22 +21,204 @@ Or install it yourself as:
22
21
 
23
22
  ## Usage
24
23
 
25
- TODO: Write usage instructions here
24
+ ### Case:下沉业务库到Pod.xcodeproj中
25
+
26
+ 在大型项目的组件化过程中,沉库操作为最耗时也是最重要的步骤。
27
+
28
+ 对于沉库,一般的操作步骤是先梳理出目标文件集合的所有依赖关系**「包含上层业务依赖、关联的Pod组件依赖以及若干层二级业务依赖和组件依赖」**,然后暴力沉库,直至编译通过。
29
+
30
+ 使用BDAnalyze可以非常方便的梳理出给定目标文件的所有依赖关系「直接业务以来、关联组件依赖、二级以及若干级依赖」
31
+
32
+ 假设我们要将头条项目中的 **tt_app_ios/Article/Model**文件进行沉库.需要准备的条件有:
33
+
34
+ ```
35
+ 1.一份编译好的头条源码工程「i.e.为了测试准确性以及完整性,需要用到所有源码信息,因此需要使用一份源码编译的头条工程」
36
+ 2.一个用来存放解析结果「解析结果为:各种文件」的绝对路径。e.g.---- /Users/bob/des
37
+ 3.头条项目在本机的绝对路径 e.g ---- /Users/bob/Git/work/tt_app_ios
38
+ 4.要分析的目标路径 e.g. ---- /Users/bob/Git/work/tt_app_ios/Article/Model「由于头条项目中使用了*.pch文件,因此解析时也要将pch文件放到目标文件下」
39
+ 5.头条项目主工程的hmap文件 e.g. ---- /Users/bob/Library/Developer/Xcode/DerivedData/Article-gynljfcyrfnppnewlnrdnebqxclg/Build/Intermediates.noindex/Article.build/Debug-iphonesimulator/newsbeta.build/newsbeta.hmap
40
+ 6.头条项目Pods工程的hmap文件[任意Pods的中的hmap文件即可] e.g. ---- /Users/bob/Library/Developer/Xcode/DerivedData/TTWenda-gynljfcyrfnppnewlnrdnebqxclg/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/TTAccountLogin.build/TTAccountLogin.hmap
41
+ ```
42
+ **其中第5条和第6条可以通过下面指令获取「以头条工程为例」**
43
+
44
+ ```ruby
45
+ BDAnalyze --searchhmap Article
46
+
47
+ ✅ 👉 /Users/bob/Library/Developer/Xcode/DerivedData/Article-cghgvmicwdcbxwfdfbahfewrpppf/Build/Intermediates.noindex/Article.build/Debug-iphonesimulator/Explore.build/Explore.hmap
48
+ ✅ 👉 /Users/bob/Library/Developer/Xcode/DerivedData/Article-cghgvmicwdcbxwfdfbahfewrpppf/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AWEVideoPlayer.build/AWEVideoPlayer.hmap
49
+
50
+ ```
51
+ 具备上述条件后,可以终端输入以下指令「**默认分析是只分析依赖的哪些Pods,但不分析Pods的.m中的二级依赖,如需分析Pods中.m文件的二级依赖,请使用--analyzePods指令**」
52
+
53
+ ```ruby
54
+ BDAnalyze --s /Users/bob/des
55
+ --proj /Users/bob/Git/工作/tt_app_ios
56
+ --tpath /Users/bob/Git/工作/tt_app_ios/Article/Model
57
+ --mHmap /Users/bob/Library/Developer/Xcode/DerivedData/Article-cghgvmicwdcbxwfdfbahfewrpppf/Build/Intermediates.noindex/Article.build/Debug-iphonesimulator/Explore.build/Explore.hmap
58
+ --pHmap /Users/bob/Library/Developer/Xcode/DerivedData/Article-cghgvmicwdcbxwfdfbahfewrpppf/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AWEVideoPlayer.build/AWEVideoPlayer.hmap
59
+ ```
60
+ 等待几秒后会输出如下:
61
+
62
+ ```ruby
63
+ ☠️ RecommendUser.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/Model/DataModel/RecommendUser.m
64
+
65
+ ☠️ PadActionButton.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/NewsBase/view/ActionButton.m
66
+
67
+ ☠️ UIColorAdditions.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/NewsBase/view/ActionButton.m
68
+
69
+ 💯 解析完毕,请到 👉 /Users/bob/des 👈 查看解析结果
70
+ ```
71
+ **其中类似警告的信息表示,代码中通过import xxx方式引入,但是实际编译时没有用到**
72
+
73
+ 然后根据提示到**/Users/bob/des**文件下,查看解析结果「实际解析关联太多,只截取部分」:
26
74
 
27
- ## Development
75
+ ```ruby
76
+ .
77
+ ├── allDenpendencyPod.txt
78
+ ├── 第10层
79
+ │   ├── HTSVideoMusicClass.h
80
+ │   ├── HTSVideoMusicDetail.h
81
+ │   ├── HTSVideoMusicList.h
82
+ │   └── containedPods.txt
83
+ ├── 第11层
84
+ │   ├── CADisplayLink+HTSBlock.h
85
+ │   ├── CADisplayLink+HTSBlock.m
86
+ │   ├── HTSVideoMusicCommon.h
87
+ │   └── containedPods.txt
88
+ ├── 第1层
89
+ │   ├── Article+TTADComputedProperties.h
90
+ │   ├── Article+TTADComputedProperties.m
91
+ │   ├── ArticleMomentManager.h
92
+ │   └── containedPods.txt
93
+ ├── 第2层
94
+ │   ├── ArticleAddressManager.h
95
+ │   ├── ArticleAddressManager.m
96
+ │   └── containedPods.txt
97
+ ├── 第3层
98
+ │   ├── ArticleAPNsManager.h
99
+ │   ├── ArticleAPNsManager.m
100
+ │   └── containedPods.txt
101
+ ├── 第4层
102
+ │   ├── APNsManager.h
103
+ │   ├── APNsManager.m
104
+ │   ├── UIViewController+BDTAccountModalPresentor.h
105
+ │   ├── UIViewController+BDTAccountModalPresentor.m
106
+ │   └── containedPods.txt
107
+ ├── 第5层
108
+ │   ├── ActionButton.h
109
+ │   ├── ActionButton.m
110
+ │   ├── UIViewController+TTVAdditions.m
111
+ │   └── containedPods.txt
112
+ ├── 第6层
113
+ │   ├── ArticleAvatarView.h
114
+ │   ├── ArticleAvatarView.m
115
+ │   ├── containedPods.txt
116
+ │   └── toutiao.hpp
117
+ ├── 第7层
118
+ │   ├── AccountButton.h
119
+ │   ├── AccountButton.m
120
+ │   ├── TTVideoRecommendView.m
121
+ │   └── containedPods.txt
122
+ ├── 第8层
123
+ │   ├── ArticleMomentListCellCommentItem.h
124
+ │   ├── ArticleMomentListCellCommentItem.m
125
+ │   └── containedPods.txt
126
+ └── 第9层
127
+ ├── HTSVideoMusicInfoDataManager.h
128
+ ├── HTSVideoMusicInfoDataManager.m
129
+ └── containedPods.txt
130
+
131
+ 11 directories, 2579 files
132
+ ```
133
+
134
+ 解析结果按照 **依赖层级** 进行分布,上图即说明 **/Users/bob/Git/工作/tt_app_ios/Article/Model** 文件集合共有11层依赖。其中每层依赖的文件夹下表示当前依赖层级的所有文件,其中对于Pods的依赖存放在每个层级的containedPods.txt文件中。在最外层的allDenpendencyPod.txt文件表示所依赖的所有Pods统计
135
+ ### Case:分析单个组件的实际依赖情况
136
+ 在沉库过程中,还有一个重要操作就是梳理已经下沉的组件的实际依赖关系,这样可以提供最小颗粒度的组件给使用方,同时有序的依赖关系会带来解析速度的提升以及维护成本的下降
137
+
138
+ 以分析头条项目中 BDAccount 组件为例,需要准备的条件有
139
+
140
+ ```ruby
141
+ 1.一份编译好的头条源码工程「i.e.为了测试准确性以及完整性,需要用到所有源码信息,因此需要使用一份源码编译的头条工程」
142
+ 2.一个用来存放解析结果「解析结果为:各种文件」的绝对路径。e.g.---- /Users/bob/des
143
+ 3.头条项目在本机的绝对路径 e.g ---- /Users/bob/Git/work/tt_app_ios
144
+ 4.要分析的目标路径 e.g. ---- /Users/bob/Git/工作/tt_app_ios/Article/Pods/BDAccount」
145
+ 5.头条项目主工程的hmap文件 e.g. ---- /Users/bob/Library/Developer/Xcode/DerivedData/Article-gynljfcyrfnppnewlnrdnebqxclg/Build/Intermediates.noindex/Article.build/Debug-iphonesimulator/newsbeta.build/newsbeta.hmap
146
+ 6.头条项目Pods工程的hmap文件[任意Pods的中的hmap文件即可] e.g. ---- /Users/bob/Library/Developer/Xcode/DerivedData/TTWenda-gynljfcyrfnppnewlnrdnebqxclg/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/TTAccountLogin.build/TTAccountLogin.hmap
147
+ 7.打开--analyzePods指令,因为需要分析组件的实现源码依赖情况
148
+ ```
149
+ 然后使用如下指令进行分析
150
+
151
+ ```ruby
152
+ BDAnalyze --s /Users/bob/des
153
+ --proj /Users/bob/Git/工作/tt_app_ios
154
+ --tpath /Users/bob/Git/工作/tt_app_ios/Article/Pods/BDAccount
155
+ --mHmap /Users/bob/Library/Developer/Xcode/DerivedData/Article-cghgvmicwdcbxwfdfbahfewrpppf/Build/Intermediates.noindex/Article.build/Debug-iphonesimulator/Explore.build/Explore.hmap
156
+ --pHmap /Users/bob/Library/Developer/Xcode/DerivedData/Article-cghgvmicwdcbxwfdfbahfewrpppf/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/AWEVideoPlayer.build/AWEVideoPlayer.hmap
157
+ --analyzePods
158
+ ```
159
+
160
+ 等待几秒后会输出如下:
28
161
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
162
+ ```ruby
163
+ ☠️ BDAccountPlatformManager.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/Pods/BDAccount/BDAccount/BDAccountSDK.h
30
164
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
165
+ ☠️ BDAccountSinaWeiboRequest.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/Pods/BDAccount/BDAccount/BDAccountSDK.h
32
166
 
33
- ## Contributing
167
+ ☠️ BDAccountFacebookRequest.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/Pods/BDAccount/BDAccount/BDAccountSDK.h
34
168
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/BDAnalyze. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
169
+ ☠️ BDAccountGoogleRequest.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/Pods/BDAccount/BDAccount/BDAccountSDK.h
36
170
 
171
+ ☠️ BDAccountTwitterRequest.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/Pods/BDAccount/BDAccount/BDAccountSDK.h
172
+
173
+ ☠️ zlib.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/Pods/Godzippa/Godzippa/NSData+Godzippa.h
174
+
175
+ ☠️ BDSDKApiObject+CompanyProduct 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/Pods/Bytedancebase/Bytedancebase/BDOpenSDK/Privates/BDSDKUserPromotionInteractor.m
176
+
177
+ ☠️ errno.h 没有被使用,不在工程目录 所属文件:/Users/bob/Git/工作/tt_app_ios/Article/Pods/TTNetworkManager/Pod/Classes/TTNetworkBase/NetworkUtil/TTNetworkHTTPErrorCodeMapper.m
178
+
179
+ 💯 解析完毕,请到 👉 /Users/bob/des 👈 查看解析结果
180
+ ```
181
+
182
+ **其中类似警告的信息表示,代码中通过import xxx方式引入,但是实际编译时没有用到**
183
+
184
+ 根据提示在 **/Users/bob/des** 下,找到解析结果如下
185
+
186
+ ```
187
+ .
188
+ ├── allDenpendencyPod.txt
189
+ ├── 第1层
190
+ │   ├── BDAccountFlowscene.h
191
+ │   ├── BDSDKApi.h
192
+ │   ├── BDSDKApi.m
193
+ │   └── containedPods.txt
194
+ ├── 第2层
195
+ │   ├── BDSDKApi+Privates.h
196
+ │   ├── BDSDKApi+Privates.m
197
+ │   └── containedPods.txt
198
+ ├── 第3层
199
+ │   ├── AFNetworking.h
200
+ │   ├── AFgzipRequestSerializer.h
201
+ │   └── containedPods.txt
202
+ ├── 第4层
203
+ │   ├── AFHTTPSessionManager.h
204
+ │   ├── AFURLRequestSerialization.h
205
+ │   └── containedPods.txt
206
+ ├── 第5层
207
+ │   ├── AFNetworkReachabilityManager.h
208
+ │   ├── AFURLSessionManager.h
209
+ │   └── containedPods.txt
210
+ └── 第6层
211
+ ├── AFSecurityPolicy.h
212
+ └── containedPods.txt
213
+
214
+ 6 directories, 19 files
215
+ ```
216
+ 其中allDenpendencyPod.txt代表目标文件所依赖的所有Pods统计,各层级表示相应的依赖层级依赖,比如第一层表示,目标文件直接依赖的情况
37
217
  ## License
38
218
 
39
219
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
220
 
41
221
  ## Code of Conduct
42
222
 
43
- Everyone interacting in the BDAnalyze project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/BDAnalyze/blob/master/CODE_OF_CONDUCT.md).
223
+ Everyone interacting in the BDAnalyze project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/BDAnalyze/blob/master/CODE_OF_CONDUCT.md).
224
+
data/lib/AnalyzeTool CHANGED
Binary file
@@ -1,3 +1,3 @@
1
1
  module BDAnalyze
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.1"
3
3
  end
data/lib/searchHMap.sh CHANGED
@@ -31,7 +31,7 @@ function displayMainHmap() {
31
31
  targetPath=$1
32
32
  cd $targetPath
33
33
  cd "Build/Intermediates.noindex/$2.build"
34
- for file in `ls`; do
34
+ for file in `ls -S`; do
35
35
  if [[ -d $file ]]; then
36
36
  cd $file
37
37
  for next in `ls`; do
@@ -56,7 +56,7 @@ function displayPodsHmap() {
56
56
  if [[ $? -ne 0 ]]; then
57
57
  exit 3
58
58
  fi
59
- for file in `ls`; do
59
+ for file in `ls -S`; do
60
60
  if [[ -d $file ]]; then
61
61
  cd $file
62
62
  for next in `ls -S`; do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BDAnalyze
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bupterambition
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-24 00:00:00.000000000 Z
11
+ date: 2018-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 2.5.2
100
+ rubygems_version: 2.5.2.3
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: BDAnalyze,A tool used for analyze the dependencies of your code and Pods