podfileDep 1.1.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,310 @@
1
+ require 'xcodeproj'
2
+ require 'pathname'
3
+
4
+ module XCProject
5
+ class ModuleItem
6
+
7
+
8
+ def initialize(module_name, module_path)
9
+ @module_name = module_name
10
+ @module_path = module_path
11
+ @podspec_path = nil
12
+ @source_files = []
13
+ end
14
+
15
+ # 组件名
16
+ attr_reader :module_name
17
+
18
+ # 组件路径
19
+ attr_reader :module_path
20
+
21
+ # 组件目录的所有被引用的文件数组
22
+ attr_reader :source_files
23
+
24
+ # podspec路径
25
+ attr_reader :podspec_path
26
+
27
+ # 添加一个文件路径进去
28
+ def add_source_file(source_file)
29
+ self.source_files << source_file
30
+ end
31
+
32
+ def update_podspec_path(podspec_path)
33
+ @podspec_path = podspec_path
34
+ end
35
+
36
+ end
37
+
38
+ class XcodeprojManager
39
+
40
+ # 缓存某个的依赖库
41
+ # {{"module_nameA":["module_nameA", module_nameB]},}
42
+ attr_reader :module_frameworks
43
+
44
+ def initialize
45
+ @module_frameworks = {}
46
+ end
47
+
48
+ # 单例方法
49
+ @@instance = XcodeprojManager.new
50
+
51
+ # 获取单例
52
+ def self.share_manager
53
+ @@instance
54
+ end
55
+
56
+ private_class_method :new
57
+
58
+ # 获取壳工程的project对象
59
+ def get_shell_project
60
+
61
+ xcodeproj_file = nil
62
+ Dir.foreach(Dir.pwd) do |file|
63
+ if file.end_with?(".xcodeproj")
64
+ xcodeproj_file = file
65
+ break
66
+ end
67
+ end
68
+
69
+ xcodeproj_path = "#{Dir.pwd}/#{xcodeproj_file}"
70
+ unless File.exist?(xcodeproj_path)
71
+ return nil
72
+ end
73
+
74
+ Xcodeproj::Project.open(xcodeproj_path)
75
+
76
+ end
77
+
78
+ #获取主APP target列表
79
+ def get_app_targets
80
+ results = []
81
+ project = self.get_shell_project
82
+ targets = project.root_object.targets
83
+ targets.each do |target|
84
+ if target.product_type.end_with?(".application")
85
+ results << target.name
86
+ end
87
+ end
88
+ results
89
+ end
90
+
91
+ # 获取壳工程的引用的文件列表
92
+ # @return Hash
93
+ def get_shell_module
94
+ project = self.get_shell_project
95
+
96
+ result_map = {}
97
+ self.reference_shell_code_file(project.root_object.main_group, result_map)
98
+ result_map
99
+ end
100
+
101
+ # 根据一个group获取其对应的引用代码文件和路径- 仅限壳工程
102
+ @private
103
+ def reference_shell_code_file(group, result_map)
104
+ # 文件引用
105
+ file_reference = Xcodeproj::Project::Object::PBXFileReference
106
+
107
+ group.children.each {|child|
108
+
109
+ if child.class != file_reference
110
+ self.reference_shell_code_file(child, result_map)
111
+ next
112
+ end
113
+
114
+ file_name = child.real_path.basename
115
+ extend_name = file_name.extname
116
+ if not extend_name == ".h" and
117
+ not extend_name == ".m" and
118
+ not extend_name == ".mm" and
119
+ not extend_name == ".pch" and
120
+ not extend_name == ".c" and
121
+ not extend_name == ".cc" and
122
+ not extend_name == ".hpp" and
123
+ not extend_name == ".cpp"
124
+ next
125
+ end
126
+
127
+ # 引用关系路径
128
+ hierarchy_path_array = child.hierarchy_path.split("/")
129
+ if hierarchy_path_array.size < 2
130
+ next
131
+ end
132
+
133
+ module_name = hierarchy_path_array[1]
134
+ module_item = result_map[module_name] ? result_map[module_name] : ModuleItem.new(module_name, child.real_path)
135
+ module_item.add_source_file(child.real_path)
136
+
137
+ result_map[module_name] = module_item
138
+ }
139
+ end
140
+
141
+
142
+ # 获取Pods下project对象
143
+ def get_pods_project
144
+
145
+ xcodeproj_path = "#{Dir.pwd}/Pods/Pods.xcodeproj"
146
+ unless File.exist?(xcodeproj_path)
147
+ return nil
148
+ end
149
+
150
+ Xcodeproj::Project.open(xcodeproj_path)
151
+
152
+ end
153
+
154
+ # 根据一个组件名获取其内部所有的framework名字 如果没有则返回自己
155
+ def frameworks_with_module_name(module_name)
156
+ if self.module_frameworks[module_name]
157
+ return self.module_frameworks[module_name]
158
+ end
159
+
160
+ module_path = self.real_path_with_module_name(module_name)
161
+ frameworks = [module_name]
162
+ self.get_framework(module_path, frameworks)
163
+ self.module_frameworks[module_name] = frameworks
164
+ frameworks
165
+ end
166
+
167
+ # 递归查找路径下的framework名字
168
+ @private
169
+ def get_framework(path, frameworks)
170
+
171
+ if File.directory?(path)
172
+ Dir.foreach(path) { |fileName|
173
+ child_path = "#{path}/#{fileName}"
174
+ if File.directory?(child_path) and not fileName.start_with?(".")
175
+ if fileName.end_with?(".framework") or fileName.end_with?(".xcframework")
176
+ framework_name = fileName.gsub(".xcframework","").gsub(".framework","")
177
+ unless frameworks.include?(framework_name)
178
+ frameworks << framework_name
179
+ end
180
+ else
181
+ self.get_framework(child_path, frameworks)
182
+ end
183
+ end
184
+ }
185
+ end
186
+ frameworks
187
+ end
188
+
189
+ # 根据一个组件的名字,获取其绝对路径
190
+ def real_path_with_module_name(module_name)
191
+ project = self.get_pods_project
192
+ project.main_group.children.each {|child|
193
+ if child.name != "Development Pods" and child.name != "Pods"
194
+ next
195
+ end
196
+
197
+ child.children.each {|sun|
198
+ if sun.name == module_name
199
+ real_path = sun.real_path
200
+ return real_path
201
+ end
202
+ }
203
+ }
204
+ nil
205
+ end
206
+
207
+ # 获取本地依赖库
208
+ # @return 数组 [ModuleItem]
209
+ def get_development_module
210
+ project = self.get_pods_project
211
+ result_map = {}
212
+ self.reference_file(project.main_group, result_map)
213
+ result_map
214
+ end
215
+
216
+ # 根据一个group获取 其对应的引用文件和路径
217
+ @private
218
+ def reference_file(group, result_map)
219
+ # 文件引用
220
+ file_reference = Xcodeproj::Project::Object::PBXFileReference
221
+
222
+ group.children.each {|child|
223
+ if child.class == file_reference and child.name != "Podfile"
224
+
225
+ # 引用关系路径
226
+ hierarchy_path_array = child.hierarchy_path.split("/")
227
+ if hierarchy_path_array.size >= 3
228
+ module_name = hierarchy_path_array[2]
229
+
230
+ module_item = result_map[module_name] ? result_map[module_name] : ModuleItem.new(module_name, child.real_path)
231
+
232
+ file_name = child.real_path.basename
233
+ extend_name = file_name.extname
234
+ if extend_name == ".podspec" or extend_name == ".podspec.json"
235
+ module_item.update_podspec_path(child.real_path)
236
+ elsif extend_name == ".h" or extend_name == ".m" or
237
+ extend_name == ".mm" or extend_name == ".pch" or
238
+ extend_name == ".c" or extend_name == ".cc" or
239
+ extend_name == ".cpp" or extend_name == ".hpp"
240
+ module_item.add_source_file(child.real_path)
241
+ end
242
+
243
+ result_map[module_name] = module_item
244
+ end
245
+ # 无论加或着不加 都跳过
246
+ next
247
+ end
248
+
249
+ if child.name == "Podfile" or
250
+ child.name == "Frameworks" or
251
+ child.name == "Pods" or
252
+ child.name == "Products" or
253
+ child.name == "Targets Support Files" or
254
+ child.name == "Support Files"
255
+ next
256
+ end
257
+
258
+ self.reference_file(child, result_map)
259
+ }
260
+ end
261
+
262
+ # 获取已引用的所有库,仅包含头文件
263
+ def get_installed_headers_module
264
+ project = self.get_pods_project
265
+
266
+ result_map = {}
267
+ self.reference_header_file(project.main_group, result_map)
268
+ result_map
269
+ end
270
+
271
+ # 获取引用的头文件
272
+ @private
273
+ def reference_header_file(group, result_map)
274
+ # 文件引用
275
+ file_reference = Xcodeproj::Project::Object::PBXFileReference
276
+
277
+ group.children.each {|child|
278
+ if child.class == file_reference
279
+
280
+ # 引用关系路径
281
+ hierarchy_path_array = child.hierarchy_path.split("/")
282
+ if hierarchy_path_array.size >= 3
283
+ module_name = hierarchy_path_array[2]
284
+
285
+ module_item = result_map[module_name] ? result_map[module_name] : ModuleItem.new(module_name, child.real_path)
286
+
287
+ file_name = child.real_path.basename
288
+ if file_name.to_s.end_with?(".h") or file_name.to_s.end_with?(".hpp") or file_name.to_s.end_with?(".pch")
289
+ module_item.add_source_file(child.real_path)
290
+ end
291
+ result_map[module_name] = module_item
292
+ end
293
+ # 无论加或着不加 都跳过
294
+ next
295
+ end
296
+
297
+ if child.name == "Podfile" or
298
+ child.name == "Frameworks" or
299
+ child.name == "Products" or
300
+ child.name == "Targets Support Files" or
301
+ child.name == "Support Files"
302
+ next
303
+ end
304
+
305
+ self.reference_header_file(child, result_map)
306
+ }
307
+ end
308
+
309
+ end
310
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ module Constants
3
+
4
+ PODFILE_LOCAL_YAML = 'PodfileLocal.yaml'
5
+ PODFILE_MODULE_YAML = 'PodfileModule.yaml'
6
+ PODFILE_THIRD_PARTY_YAML = 'PodfileThirdParty.yaml'
7
+ PODFILE_LOCK = 'Podfile.lock'
8
+ PODFILE = 'Podfile'
9
+
10
+ LIBLIBARYS = ["time","removefile","AppleTextureEncoder","standards","AvailabilityMacros","semaphore","SystemHealthClient","dns_sd","ftw","checkint","pwd","bitstring","utime","err","CommonCrypto","inttypes","resolv","c++","_ctermid","stdlib","sysdir","unwind","fts","vis","AvailabilityVersions","membership","libxml2","ulimit","_stdio","ntsid","net","notify_keys","CMakeLists.txt","AssertMacros","float","aio","libxml","ConditionalMacros","locale","fmtmsg","unicode","_wctype","cpio","langinfo","xlocale","limits","Endian","unwind_itanium","_types","db","bank","_ctype","unistd","stddef","dispatch","wctype","fcntl","mach_debug","Availability","stringlist","tar","readpassphrase","_locale","ttyent","bzlib","cache","signal","dirent","mpool","libDER","unwind_arm_ehabi","spawn","crt_externs","simd","regex","AvailabilityInternal","arpa","syslog","bsm","netinet","libunwind","libgen","corpses","rpcsvc","monetary","compression","expat_external","setjmp","tgmath","notify","getopt","_regex","dlfcn","strings","TargetConditionals","fnmatch","pthread","xlocale","execinfo","networkext","printf","architecture","alloca","sys","iconv","fenv","expat","grp","secure","ctype","fstab","pthread_spis","machine","SystemHealthManager","voucher","wordexp","zlib","nl_types","paths","AppleEXR","wchar","sqlite3","util","gethostuuid","sched","sqlite3ext","iso646","Block","netdb","pthread","math","memory","asl","__wctype","mach","errno","device","termios","copyfile","os","xattr_flags","poll","_xlocale","stdio","mach-o","malloc","string_x86","arm","Spatial","__libunwind_config","nameser","dns","_types","rpc","netinet6","pthread_impl","objc","MacTypes","libkern","uuid","search","assert","AppleArchive","cache_callbacks","dns_util","glob","ifaddrs","utmpx","sandbox","arm64","stdint","complex","runetype","zconf","ucontext","sysexits","string","ndbm"]
11
+ FRAMEWORKS = ["MetricKit","Network","GameKit","AddressBookUI","CreateML","Speech","SafariServices","ProximityReader","Metal","AppClip","QuartzCore","CoreGraphics","StoreKit","GSS","CoreML","WatchConnectivity","UserNotificationsUI","ARKit","CoreLocationUI","MetalPerformanceShaders","AutomaticAssessmentConfiguration","ExternalAccessory","MediaPlayer","LinkPresentation","IdentityLookupUI","MediaToolbox","UIKit","MessageUI","MetalFX","CoreNFC","HomeKit","CryptoKit","ScreenTime","NewsstandKit","MLCompute","NaturalLanguage","CoreVideo","MetalKit","OSLog","PDFKit","CoreText","UniformTypeIdentifiers","IOKit","ManagedSettings","AVFoundation","Accelerate","DeviceCheck","ImageIO","BackgroundTasks","FamilyControls","ClockKit","CoreBluetooth","ThreadNetwork","SensorKit","Security","Contacts","CarPlay","ExtensionFoundation","RealityKit","PhotosUI","RoomPlan","ReplayKit","IOSurface","SpriteKit","MobileCoreServices","IntentsUI","QuickLookThumbnailing","CoreMedia","BusinessChat","Intents","ColorSync","VideoSubscriberAccount","PencilKit","ManagedSettingsUI","CoreServices","HealthKit","MultipeerConnectivity","BackgroundAssets","WebKit","NotificationCenter","SystemConfiguration","GameController","CoreTelephony","ActivityKit","AVFAudio","AssetsLibrary","AudioUnit","FileProvider","DeviceActivity","Social","IdentityLookup","Matter","CoreImage","CoreAudio","MusicKit","DeviceDiscoveryExtension","MediaSetup","AutomatedDeviceEnrollment","CoreAudioKit","ExposureNotification","ClassKit","VisionKit","SwiftUI","Combine","ModelIO","PHASE","SharedWithYou","OpenGLES","MetalPerformanceShadersGraph","CreateMLComponents","Accounts","FileProviderUI","ShazamKit","CarKey","RealityFoundation","QuickLook","AppIntents","AuthenticationServices","WeatherKit","DataDetection","AudioToolbox","NearbyInteraction","ContactsUI","CoreSpotlight","LocalAuthentication","MatterSupport","Foundation","AdSupport","LocalAuthenticationEmbeddedUI","Accessibility","HealthKitUI","PushKit","Vision","CoreAudioTypes","NetworkExtension","ExtensionKit","OpenAL","EventKit","MediaAccessibility","Charts","iAd","MapKit","AppTrackingTransparency","CoreHaptics","CallKit","CoreFoundation","TabularData","CoreMotion","AVRouting","WidgetKit","AVKit","AddressBook","SoundAnalysis","GroupActivities","CoreLocation","CloudKit","SharedWithYouCore","CFNetwork","Photos","JavaScriptCore","GameplayKit","PushToTalk","CoreMIDI","Twitter","PassKit","ImageCaptureCore","CoreData","GLKit","AdServices","Messages","CryptoTokenKit","VideoToolbox","SafetyKit","UserNotifications","DeveloperToolsSupport","CoreTransferable","EventKitUI","SceneKit"]
12
+
13
+ end
@@ -0,0 +1,52 @@
1
+ require 'pathname'
2
+
3
+ module ModifyCode
4
+ class Modify
5
+ def self.modify_fb
6
+
7
+ self.replace_str("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm",
8
+ "layoutCache[currentClass] = ivars;",
9
+ "layoutCache[(id<NSCopying>)currentClass] = ivars;")
10
+ self.replace_str("Pods/FBRetainCycleDetector/fishhook/fishhook.c",
11
+ "indirect_symbol_bindings[i] = cur->rebindings[j].replacement;",
12
+ "if(i < (sizeof(indirect_symbol_bindings) /sizeof(indirect_symbol_bindings[0]))) {indirect_symbol_bindings[i]=cur->rebindings[j].replacement;}")
13
+
14
+ new_string = "#import <objc/runtime.h>
15
+ #import <malloc/malloc.h>"
16
+ self.replace_str("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Graph/FBObjectiveCGraphElement.mm",
17
+ "#import <objc/runtime.h>",
18
+ new_string)
19
+
20
+ new_string = "malloc_zone_t *zone = malloc_zone_from_ptr((__bridge void *)object); if (zone) { Class aCls=object_getClass(object);"
21
+ self.replace_str("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Graph/FBObjectiveCGraphElement.mm",
22
+ "Class aCls = object_getClass(object);",
23
+ new_string)
24
+
25
+ new_string = "}
26
+ # endif"
27
+ self.replace_str("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Graph/FBObjectiveCGraphElement.mm",
28
+ "#endif",
29
+ new_string)
30
+
31
+ end
32
+
33
+ # 替换文件内的字符串
34
+ def self.replace_str(file_path, find, replace)
35
+ unless File.exist?(file_path)
36
+ return
37
+ end
38
+ replace_string = replace
39
+ FileUtils.chmod("+w", file_path)
40
+ text = File.read(file_path)
41
+ replace = text.gsub(find, replace)
42
+ if text != replace
43
+ File.open(file_path, "w") do |file|
44
+ file.puts replace
45
+ end
46
+ file_name = File.basename(file_path)
47
+ puts "代码替换: #{file_name} (#{find} => #{replace_string})"
48
+ end
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ require_relative 'constants'
2
+ require 'yaml'
3
+
4
+ module PodfileLock
5
+ class PodfileLockManager
6
+ # 读取podfile.lock
7
+ def self.podfile_lock_content
8
+ podfile_lock = Constants::PODFILE_LOCK
9
+
10
+ unless File.exist?(podfile_lock)
11
+ return {}
12
+ end
13
+
14
+ YAML.load_file(podfile_lock)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,72 @@
1
+ require_relative '../check/xcodeproj'
2
+ require_relative '../constants'
3
+ module Project
4
+ class ProjectManager
5
+
6
+ def self.yaml_deal
7
+ puts "yaml文件处理"
8
+ self.add_yaml
9
+ self.add_local_yaml_ignore
10
+ end
11
+
12
+ def self.add_yaml
13
+
14
+ podfile_local_yaml = Constants::PODFILE_LOCAL_YAML
15
+ podfile_module_yaml = Constants::PODFILE_MODULE_YAML
16
+ podfile_third_party_yaml = Constants::PODFILE_THIRD_PARTY_YAML
17
+
18
+ project_manager = XCProject::XcodeprojManager.share_manager
19
+ pods_project = project_manager.get_pods_project
20
+
21
+ did_add = []
22
+
23
+ pods_project.main_group.children.each {|child|
24
+ did_add << child.display_name
25
+ }
26
+
27
+ unless did_add.include?(podfile_local_yaml)
28
+ path = "#{Dir.pwd}/#{podfile_local_yaml}"
29
+ pods_project.new_file(path)
30
+ end
31
+
32
+ unless did_add.include?(podfile_module_yaml)
33
+ path = "#{Dir.pwd}/#{podfile_module_yaml}"
34
+ pods_project.new_file(path)
35
+ end
36
+
37
+ unless did_add.include?(podfile_third_party_yaml)
38
+ path = "#{Dir.pwd}/#{podfile_third_party_yaml}"
39
+ pods_project.new_file(path)
40
+ end
41
+
42
+ pods_project.sort(:groups_position => :below)
43
+ pods_project.save
44
+ end
45
+
46
+ # 把local.yaml添加到忽略文件中
47
+ def self.add_local_yaml_ignore
48
+
49
+ gitignore = ".gitignore"
50
+ podfile_local_yaml = Constants::PODFILE_LOCAL_YAML
51
+
52
+ contain = false
53
+ gitignore_path= "#{Dir.pwd}/#{gitignore}"
54
+ if File.exist?(gitignore_path)
55
+ line_array = IO.readlines(gitignore_path)
56
+ line_array.each do |line|
57
+ line = line.gsub(" ", "").gsub("\n", "")
58
+ if line == podfile_local_yaml
59
+ contain = true
60
+ break
61
+ end
62
+ end
63
+ end
64
+
65
+ unless contain
66
+ File.open(gitignore_path, 'a+') { |file|
67
+ file.write(podfile_local_yaml)
68
+ }
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,141 @@
1
+ require_relative '../check/xcodeproj'
2
+ require_relative '../podfilelock'
3
+
4
+ module Unused
5
+ class UnusedManager
6
+
7
+ # 打印未被引用的依赖库
8
+ def self.check_unused
9
+ puts "\n未被引用的组件检查中..."
10
+ start = (Time.now.to_f * 1000).to_i
11
+
12
+ podfile_lock_manager = PodfileLock::PodfileLockManager
13
+ project_manager = XCProject::XcodeprojManager.share_manager
14
+
15
+ # podfile.lock的内容
16
+ lock_content = podfile_lock_manager.podfile_lock_content
17
+
18
+ # 所有已安装的模块
19
+ installed_modules = self.get_installed_modules(lock_content)
20
+
21
+ # 壳工程里引用的所有模块
22
+ shell_modules = project_manager.get_shell_module
23
+ if installed_modules.size == 0
24
+ return
25
+ end
26
+
27
+ # 未使用的列表
28
+ unused_list = []
29
+ installed_modules.each do |module_item|
30
+
31
+ module_name = module_item.keys[0]
32
+ real_module_name = module_name.include?("/") ? module_name.split("/")[0] : module_name #处理有子模块的情况
33
+
34
+ used = self.dep_used(real_module_name, installed_modules)
35
+
36
+ unless used
37
+ used = self.dep_used_in_shell_modules(real_module_name, shell_modules) #在壳工程里检验看用到没
38
+ end
39
+
40
+ if not used and not unused_list.include?(real_module_name)
41
+ unused_list << real_module_name
42
+ end
43
+ end
44
+
45
+ if unused_list.size >0
46
+ puts unused_list
47
+ puts "以上组件未被任何地方引用"
48
+ end
49
+
50
+ duration = ((Time.now.to_f * 1000).to_i - start)*0.001
51
+ puts "未被引用的组件检查完毕! 共检查#{installed_modules.size.to_s}个组件 耗时:#{duration.round(2)}秒"
52
+ end
53
+
54
+ # 获取某个库是否在壳工程内被使用
55
+ def self.dep_used_in_shell_modules(module_name, shell_modules)
56
+ used = false
57
+ shell_modules.each do |shell_module, shell_module_item|
58
+ shell_module_item.source_files.each{|source_file|
59
+ if self.dep_used_in_file(module_name, source_file)
60
+ used = true
61
+ break
62
+ end
63
+ }
64
+ end
65
+ used
66
+ end
67
+
68
+ # 获取某个库是否在文件内被使用
69
+ def self.dep_used_in_file(module_name, file_path)
70
+ if File.directory?(file_path)
71
+ return false
72
+ end
73
+
74
+ line_array = IO.readlines(file_path)
75
+ line_array.each_with_index { |line, index|
76
+ unless line.start_with?("#import <")
77
+ next
78
+ end
79
+
80
+ line_split_array = line.split("/")
81
+ if line_split_array.size < 1
82
+ next
83
+ end
84
+
85
+ line_module_name = line_split_array[0].gsub("#import <","")
86
+
87
+ real_module_name = module_name.include?("/") ? module_name.split("/")[0] : module_name #处理有子模块的情况
88
+
89
+ if real_module_name == line_module_name
90
+ return true
91
+ end
92
+ }
93
+ false
94
+ end
95
+
96
+ # 获取某个库是否被使用
97
+ # @return bool
98
+ def self.dep_used(module_name, installed_modules)
99
+
100
+ installed_modules.each do |module_item|
101
+ module_item.each_value {|deps|
102
+ deps.each{|dep|
103
+ real_dep = dep.include?("/") ? dep.split("/")[0] : dep #处理有子模块的情况
104
+ if real_dep == module_name
105
+ return true
106
+ end
107
+ }
108
+ }
109
+ end
110
+ return false
111
+ end
112
+
113
+ # 获取已安装的依赖库列表
114
+ # @return Array
115
+ def self.get_installed_modules(lock_content)
116
+ all_modules = lock_content["PODS"]
117
+
118
+ result_array = []
119
+ all_modules.each do |item|
120
+ if item.class == String
121
+ dep = item.split(" (")[0]
122
+ result_array << {dep => []}
123
+ elsif item.class == Hash
124
+ item_key = item.keys[0]
125
+ dep = item_key.split(" (")[0]
126
+
127
+ item_value = item.values[0]
128
+ child_deps = []
129
+ item_value.each { |child|
130
+ child_deps << child.split(" (")[0]
131
+ }
132
+
133
+ result_array << {dep => child_deps}
134
+ end
135
+ end
136
+
137
+ result_array
138
+ end
139
+
140
+ end
141
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PodfileDep
4
- VERSION = "1.1.3"
4
+ VERSION = "2.0.0"
5
5
  end