podfileDep 2.1.6 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,97 +1,51 @@
1
+ require_relative 'yaml_pod'
1
2
  require_relative '../version'
2
3
  require_relative '../constants'
3
4
  require_relative '../check/xcodeproj'
4
5
 
5
6
  module Pod
7
+ class YamlDep
6
8
 
7
- class YamlRely
8
- attr_accessor :module_name, :pod, :subspecs, :version, :git, :tag, :branch, :podspec, :configurations, :path, :inhibit_warnings, :source, :binary
9
- def initialize(pod)
10
- @pod = pod
11
- end
12
-
13
- def option
14
- result = {:configurations => self.configurations, :inhibit_warnings => self.inhibit_warnings, :subspecs => self.subspecs}
15
- if self.path #路径依赖
16
- result[:path] = self.path
17
- elsif self.podspec #podspec引用
18
- result[:podspec] = self.podspec
19
- elsif self.version #版本号依赖
20
- result[:source] = self.source
21
- elsif self.git #git仓库引用
22
- result[:git] = self.git
23
- if self.tag #tag引用
24
- result[:tag] = self.tag
25
- else #分支引用 或着未指定分支 也按分支引用
26
- result[:branch] = self.branch
27
- end
28
- end
29
- result
30
- end
9
+ # 主工程target列表
10
+ # @return [String]
11
+ attr_accessor :targets
31
12
 
32
- end
33
- class YamlManager
13
+ # 主工程里所有yaml文件定义的依赖
14
+ # @return {String, {String, [Pod:YamlPod]}}
15
+ attr_accessor :yaml_deps
34
16
 
35
- attr_accessor :local_yaml_deps
17
+ # 解析后生成主工程里所有yaml文件定义的依赖
18
+ # @return {String, [Pod:YamlPod]}
19
+ attr_accessor :all_deps
36
20
 
37
- def initialize
38
- @local_yaml_deps = []
39
- end
21
+ # 所有的targets对应的依赖库列表
22
+ # @return {String, [Pod:YamlPod]}
23
+ attr_accessor :targets_dependencies
40
24
 
41
- # 单例方法
42
- @@instance = YamlManager.new
25
+ attr_accessor :podfile_local_yaml
26
+ attr_accessor :podfile_module_yaml
27
+ attr_accessor :podfile_third_party_yaml
43
28
 
44
- # 获取单例
45
- def self.share_manager
46
- @@instance
29
+ def initialize
30
+ super
31
+ @targets = []
32
+ @yaml_deps = {}
33
+ @all_deps = {}
34
+ @targets_dependencies = {}
35
+ @podfile_local_yaml = Constants::PODFILE_LOCAL_YAML
36
+ @podfile_module_yaml = Constants::PODFILE_MODULE_YAML
37
+ @podfile_third_party_yaml = Constants::PODFILE_THIRD_PARTY_YAML
47
38
  end
48
39
 
49
- private_class_method :new
50
-
51
- def analysis_yaml(podfile, old)
52
-
53
- # 获取targets列表
54
- project_manager = XCProject::XcodeprojManager.share_manager
55
-
56
- targets = project_manager.get_app_targets
57
-
58
- podfile_local_yaml = Constants::PODFILE_LOCAL_YAML
59
- podfile_module_yaml = Constants::PODFILE_MODULE_YAML
60
- podfile_third_party_yaml = Constants::PODFILE_THIRD_PARTY_YAML
61
-
62
- # 检查参数
63
- check_param(targets)
64
-
65
- # 生成YAML文件
66
- generate_local_yaml(podfile_local_yaml)
67
- generate_module_yaml(podfile_module_yaml, "# 企业内部组件")
68
- generate_module_yaml(podfile_third_party_yaml, "# 第三方维护组件")
69
-
70
- # 读取yaml依赖
71
- yaml_dependencies = {}
72
- read_yaml_dependencies(podfile_third_party_yaml,false ,yaml_dependencies)
73
- read_yaml_dependencies(podfile_module_yaml,false ,yaml_dependencies)
74
- read_yaml_dependencies(podfile_local_yaml,true ,yaml_dependencies)
75
-
76
- # 打印依赖
77
- print_dependencies(yaml_dependencies)
78
-
79
- # 为所有target生成依赖
80
- targets_dependencies = {}
81
- update_target_dependencies(targets, yaml_dependencies, targets_dependencies)
82
-
83
- # 兼容老方式
84
- if old
85
- return targets_dependencies
86
- end
40
+ def install_yaml_dep(podfile)
41
+ analysis_yaml_dep
87
42
 
88
- # 存储所有依赖
89
- store_dependencies(targets_dependencies, podfile) do|name|
43
+ install_dependencies(targets_dependencies, podfile) do|name|
90
44
  yield(name) if block_given?
91
45
  end
92
46
  end
93
47
 
94
- def store_dependencies(targets, podfile)
48
+ def install_dependencies(targets, podfile)
95
49
  # 存储所有的依赖
96
50
  targets.each { |name, dependencies|
97
51
  podfile.target name do
@@ -109,165 +63,113 @@ module Pod
109
63
  targets
110
64
  end
111
65
 
112
- # 检查方法调用的参数
113
- def check_param(targets)
114
- msg = "❌ 参数需要填写target名字, 参数类型是字符串格式的数组。例如[\"test1\", \"test2\"]"
115
- unless targets.class == Array
116
- puts msg
117
- exit!
118
- end
66
+ # 获取非扩展target定义在yaml文件的依赖
67
+ # @return targets_dependencies
68
+ def analysis_yaml_dep
69
+ init_main_targets
70
+ generate_yaml
71
+ read_yaml_deps
72
+ analyzing_yaml_deps
73
+ print_yaml_deps
74
+ resolve_targets_deps
75
+ end
119
76
 
77
+ def resolve_targets_deps
120
78
  targets.each { |target|
121
- unless target.class == String
122
- puts msg
123
- exit!
124
- end
79
+ targets_dependencies[target] = all_deps.values
125
80
  }
81
+ targets_dependencies
126
82
  end
127
83
 
128
- # 校验yaml文件写法是否正确
129
- def yaml_content(yaml_name)
130
- unless File.exist?(yaml_name)
131
- puts "文件不存在:"+yaml_name
132
- return nil
133
- end
134
-
135
- begin
136
- yaml_content = YAML.load_file(yaml_name)
137
- rescue Exception => e
138
- puts e
139
- puts yaml_name+'文件解析异常, 请检查 ⬆️'
140
- exit!
141
- end
84
+ # 读取yaml文件的依赖
85
+ def read_yaml_deps
86
+ read_yaml_deps_file(podfile_third_party_yaml)
87
+ read_yaml_deps_file(podfile_module_yaml)
88
+ read_yaml_deps_file(podfile_local_yaml)
89
+ end
142
90
 
143
- prefix_message = "解析:"+yaml_name + "=> "
144
- unless yaml_content.class == Hash
145
- puts "#{prefix_message}共0个依赖(文件不是keyValue形式)"
146
- return nil
147
- end
91
+ # 解析所有的依赖
92
+ def analyzing_yaml_deps
93
+ yaml_deps.each do |yaml_name, deps|
94
+ if yaml_name == podfile_local_yaml
95
+ clean = false #记录只能清一次就够了
96
+ deps.each { |name, dep|
97
+ real_name = name.split("/")[0]
98
+ # 有子模块 把之前的全部清空
99
+ if Array(dep.subspecs).size > 0 or Array(dep.configurations).size > 0
100
+ unless clean
101
+ all_deps.delete_if{|pod_name|
102
+ real_pod_name = pod_name.split("/")[0]
103
+ if real_pod_name == real_name
104
+ puts "✅ #{pod_name}被#{yaml_name}覆盖"
105
+ end
106
+ real_pod_name == real_name
107
+ }
108
+ clean = true
109
+ end
110
+ end
148
111
 
149
- unless yaml_content.key?('PODS')
150
- puts "#{prefix_message}共0个依赖(文件内的key[PODS]不存在)"
151
- return nil
152
- end
112
+ if all_deps.has_key?(name)
113
+ puts "#{name}被#{yaml_name}覆盖"
114
+ end
153
115
 
154
- unless yaml_content['PODS'].class == Array
155
- puts "#{prefix_message}共0个依赖(文件配置的依赖PODS下边不是数组或数组为空)"
156
- return nil
157
- end
116
+ all_deps[name] = dep
117
+ }
118
+ else
119
+ @all_deps.merge!(deps)
120
+ end
158
121
 
159
- podfile_local_yaml = Constants::PODFILE_LOCAL_YAML
160
- if yaml_name != podfile_local_yaml and (not yaml_content['SOURCE'] or yaml_content['SOURCE'].class != String)
161
- puts "#{yaml_name}的SOURCE字段必须是字符串且不为空"
162
- exit!
163
122
  end
123
+ all_deps
124
+ end
164
125
 
165
- if yaml_name != podfile_local_yaml and (not yaml_content['BINARY_SOURCE'] or yaml_content['BINARY_SOURCE'].class != String)
166
- puts "#{yaml_name}的BINARY_SOURCE字段必须是字符串且不为空"
167
- exit!
168
- end
126
+ def read_yaml_deps_file(yaml_name)
169
127
 
170
- yaml_content
128
+ yaml_content = read_yaml_content(yaml_name)
171
129
 
172
- end
130
+ unless yaml_content
131
+ return
132
+ end
173
133
 
174
- # 读取yaml依赖
175
- def read_yaml_dependencies(yaml_name, can_cover, yaml_dependencies)
134
+ if yaml_name != podfile_local_yaml
135
+ if not yaml_content["SOURCE"] or yaml_content["SOURCE"].class != String
136
+ puts "#{yaml_name}的SOURCE字段必须是字符串且不为空"
137
+ exit!
138
+ end
139
+ if yaml_name != podfile_local_yaml and not yaml_content["BINARY_SOURCE"] or yaml_content["BINARY_SOURCE"].class != String
140
+ puts "#{yaml_name}的BINARY_SOURCE字段必须是字符串且不为空"
141
+ exit!
142
+ end
143
+ end
176
144
 
177
- # 检查写法
178
- yaml_content = yaml_content(yaml_name)
145
+ unless yaml_content["PODS"]
146
+ puts "#{yaml_name}共0个依赖(文件内的key[PODS]不存在)"
147
+ return
148
+ end
179
149
 
180
- unless yaml_content
150
+ if yaml_content["PODS"].class != Array
151
+ puts "#{yaml_name}共0个依赖(文件配置的依赖PODS项不是数组或数组为空)"
181
152
  return
182
153
  end
183
154
 
184
155
  # 读取默认源码source
185
- default_source_source = nil
186
- if yaml_content.key?('SOURCE') and yaml_content['SOURCE'].class == String
187
- default_source_source = yaml_content['SOURCE']
188
- end
156
+ default_source_source = yaml_content['SOURCE']
189
157
 
190
158
  # 读取默认二进制source
191
- default_binary_source = nil
192
- if yaml_content.key?('BINARY_SOURCE') and yaml_content['BINARY_SOURCE'].class == String
193
- default_binary_source = yaml_content['BINARY_SOURCE']
194
- end
159
+ default_binary_source = yaml_content['BINARY_SOURCE']
195
160
 
196
161
  # 依赖列表
197
162
  dependencies_pods = yaml_content['PODS']
198
- puts "解析:#{yaml_name} => 共#{dependencies_pods.size.to_s}个依赖"
199
163
 
200
164
  # 当前yaml文件的组件名字 用来校验本文件内是否重复
201
165
  dependencies_name = []
202
166
 
167
+ yaml_dependencies = {}
168
+
203
169
  # 遍历依赖库列表
204
170
  dependencies_pods.each { |dependency|
205
171
 
206
- # 不支持提醒
207
- available_keys = %w[module pod subspecs path podspec version git tag branch configurations inhibit_warnings source binary]
208
- dependency.each_key { |key|
209
- unless available_keys.include?(key)
210
- gem_name = "podfileDep"
211
- puts "❌ #{yaml_name}: 当前#{gem_name}版本(#{PodfileDep::VERSION})不支持字段#{key}"
212
- puts "请检查对应字段或尝试执行如下命令升级"
213
- puts "gem uninstall #{gem_name} && gem install #{gem_name}"
214
- exit!
215
- end
216
- }
217
-
218
- # 校验字段
219
- unless dependency['pod']
220
- puts "#{yaml_name}: pod 字段(组件名字)必须存在,请检查:"
221
- exit!
222
- end
223
-
224
- unless dependency['path'] or dependency['podspec'] or dependency['version'] or dependency['git'] or dependency['tag'] or dependency['branch']
225
- puts "#{yaml_name} - #{dependency['pod']}: path/podspec/version/git/tag/branch 字段需至少有一个存在,请检查"
226
- exit!
227
- end
228
-
229
- if dependency['tag'] and dependency['branch'] and not dependency['git']
230
- puts "#{yaml_name} - #{dependency['pod']}: 请为此组件配置git字段"
231
- exit!
232
- end
233
-
234
- # 检查数据类型
235
- if dependency['configurations'] and dependency['configurations'].class != Array
236
- puts "#{yaml_name} - #{dependency['pod']} - #{dependency['configurations']}: configurations字段必须是数组,例如:['Debug','Release']"
237
- exit!
238
- end
239
-
240
- if dependency['subspecs'] and dependency['subspecs'].class != Array
241
- puts "#{yaml_name} - #{dependency['pod']} - #{dependency['subspecs']}: subspecs字段必须是数组,例如:['A','B','C']"
242
- exit!
243
- end
244
-
245
- # 校验自身文件重复
246
- if dependencies_name.include?(dependency['pod'])
247
- puts "❌ 发现#{yaml_name}内重复组件:#{dependency['pod']},请检查并删除重复依赖:"
248
- exit!
249
- else
250
- dependencies_name << dependency['pod']
251
- end
252
- # 校验和总的依赖的重复
253
- repeats = []
254
- if yaml_dependencies.key?(dependency['pod']) and not can_cover
255
- repeats << dependency['pod']
256
- end
257
- if repeats.size > 0
258
- puts "❌ 发现重复组件如下,请检查并删除重复依赖:"
259
- puts repeats
260
- exit!
261
- end
262
-
263
- # 警告
264
- podfile_local_yaml = Constants::PODFILE_LOCAL_YAML
265
- if dependency['path'] and not can_cover
266
- puts "⚠️ 组件#{dependency['pod']}使用path依赖方式应该写在#{podfile_local_yaml}"
267
- end
268
- if dependency['podspec'] and not can_cover
269
- puts "⚠️ 组件#{dependency['pod']}使用podspec依赖方式应该写在#{podfile_local_yaml}"
270
- end
172
+ check_pod(dependency, yaml_name, dependencies_name)
271
173
 
272
174
  # 默认值
273
175
  source = dependency['source']
@@ -276,36 +178,16 @@ module Pod
276
178
  end
277
179
  inhibit_warnings = dependency['inhibit_warnings'] ? !!dependency['inhibit_warnings'] : false
278
180
  binary = dependency['binary'] ? !!dependency['binary'] : true
279
- version = (dependency['path'] or dependency['podspec']) ? nil :dependency['version']
280
-
281
- # 记录
282
- if yaml_name == Constants::PODFILE_LOCAL_YAML
283
- self.local_yaml_deps << dependency['pod']
284
- end
285
-
286
- # subspecs的覆盖前 把之前展开的全部清空
287
- if can_cover and Array(dependency['subspecs']).size > 0
288
- pod_prefix = dependency['pod']
289
- yaml_dependencies.delete_if{|key, value|
290
- key.start_with?(pod_prefix)
291
- }
292
- puts "✅ #{dependency['pod']}被#{yaml_name}覆盖"
293
- end
294
181
 
295
- # 记录覆盖
296
- if yaml_dependencies.key?(dependency['pod']) and can_cover
297
- puts "✅ #{dependency['pod']}被#{yaml_name}覆盖"
298
- end
299
-
300
- need_expand = !!(Array(dependency['configurations']).size > 0 or can_cover)
301
- if Array(dependency['subspecs']).size > 0 and need_expand
182
+ # configurations和subspecs cocoapods不能同时支持,所以要展开
183
+ if Array(dependency['subspecs']).size > 0 and Array(dependency['configurations']).size > 0
302
184
  dependency['subspecs'].each {|subspec|
303
- dep = YamlRely.new(pod = "#{dependency['pod']}/#{subspec}")
185
+ dep = YamlPod.new(pod = "#{dependency['pod']}/#{subspec}")
304
186
  dep.module_name = dependency['module']
305
187
  dep.subspecs = nil
306
188
  dep.path = dependency['path']
307
189
  dep.podspec = dependency['podspec']
308
- dep.version = version
190
+ dep.version = dependency['version']
309
191
  dep.git = dependency['git']
310
192
  dep.tag = dependency['tag']
311
193
  dep.branch = dependency['branch']
@@ -317,12 +199,12 @@ module Pod
317
199
  }
318
200
 
319
201
  else
320
- dep = YamlRely.new(pod = dependency['pod'])
202
+ dep = YamlPod.new(pod = dependency['pod'])
321
203
  dep.module_name = dependency['module']
322
204
  dep.subspecs = dependency['subspecs']
323
205
  dep.path = dependency['path']
324
206
  dep.podspec = dependency['podspec']
325
- dep.version = version
207
+ dep.version = dependency['version']
326
208
  dep.git = dependency['git']
327
209
  dep.tag = dependency['tag']
328
210
  dep.branch = dependency['branch']
@@ -334,24 +216,124 @@ module Pod
334
216
  end
335
217
  }
336
218
 
219
+ yaml_deps[yaml_name] = yaml_dependencies
220
+
221
+ yaml_dependencies
337
222
  end
338
223
 
339
- # 生成传进来的target的依赖库列表
340
- def update_target_dependencies(targets, yaml_dependencies, targets_dependencies)
341
- temp_array = []
342
- yaml_dependencies.each_value { |value|
343
- temp_array << value
224
+ def check_pod(dependency, yaml_name, dependencies_name)
225
+ # 不支持提醒
226
+ available_keys = %w[module pod subspecs path podspec version git tag branch configurations inhibit_warnings source binary]
227
+ dependency.each_key { |key|
228
+ unless available_keys.include?(key)
229
+ gem_name = "podfileDep"
230
+ puts "❌ #{yaml_name}: 当前#{gem_name}版本(#{PodfileDep::VERSION})不支持字段#{key}"
231
+ puts "请检查对应字段或尝试执行如下命令升级"
232
+ puts "gem uninstall #{gem_name} && gem install #{gem_name}"
233
+ exit!
234
+ end
344
235
  }
345
236
 
346
- targets.each { |target|
347
- targets_dependencies[target] = temp_array
348
- }
237
+ # 校验字段
238
+ unless dependency['pod']
239
+ puts "#{yaml_name}: pod 字段(组件名字)必须存在,请检查:"
240
+ exit!
241
+ end
242
+
243
+ current_type = nil
244
+ current_type = check_only_one_dep(dependency, "path", current_type, yaml_name)
245
+ current_type = check_only_one_dep(dependency, "podspec", current_type, yaml_name)
246
+ current_type = check_only_one_dep(dependency, "version", current_type, yaml_name)
247
+ current_type = check_only_one_dep(dependency, "tag", current_type, yaml_name)
248
+ current_type = check_only_one_dep(dependency, "branch", current_type, yaml_name)
249
+
250
+ unless current_type
251
+ puts "#{yaml_name} - #{dependency['pod']}: path/podspec/version/git/tag/branch 字段请指定其中一个"
252
+ exit!
253
+ end
254
+
255
+ unless dependency['git']
256
+ if dependency['tag']
257
+ puts "#{yaml_name} - #{dependency['pod']}: 你指定了tag,但未配置git地址,请为此组件配置git字段"
258
+ exit!
259
+ end
260
+ if dependency['branch']
261
+ puts "#{yaml_name} - #{dependency['pod']}: 你指定了branch,但未配置git地址,请为此组件配置git字段"
262
+ exit!
263
+ end
264
+ end
265
+
266
+ # 检查数据类型
267
+ if dependency['configurations'] and dependency['configurations'].class != Array
268
+ puts "#{yaml_name} - #{dependency['pod']} - #{dependency['configurations']}: configurations字段必须是数组,例如:['Debug','Release']"
269
+ exit!
270
+ end
271
+
272
+ if dependency['subspecs'] and dependency['subspecs'].class != Array
273
+ puts "#{yaml_name} - #{dependency['pod']} - #{dependency['subspecs']}: subspecs字段必须是数组,例如:['A','B','C']"
274
+ exit!
275
+ end
276
+
277
+ # 校验自身文件重复
278
+ if dependencies_name.include?(dependency['pod'])
279
+ puts "❌ 发现#{yaml_name}内重复组件:#{dependency['pod']},请检查并删除重复依赖:"
280
+ exit!
281
+ else
282
+ dependencies_name << dependency['pod']
283
+ end
284
+
285
+ # 警告
286
+ if dependency['path'] and yaml_name != podfile_local_yaml
287
+ warn "⚠️ 组件#{dependency['pod']}使用path依赖方式应该写在#{podfile_local_yaml}"
288
+ end
289
+ if dependency['podspec'] and yaml_name != podfile_local_yaml
290
+ warn "⚠️ 组件#{dependency['pod']}使用podspec依赖方式应该写在#{podfile_local_yaml}"
291
+ end
292
+
293
+ end
294
+
295
+ def check_only_one_dep(dependency, key, current_type, yaml_name)
296
+ if dependency[key]
297
+ if current_type
298
+ puts "#{yaml_name} - #{dependency['pod']}: #{current_type}字段和#{key}只能使用其中一个,请删除不需要的一个"
299
+ exit!
300
+ else
301
+ return key
302
+ end
303
+ end
304
+ current_type
305
+ end
306
+
307
+ def read_yaml_content(yaml_name)
308
+ unless File.exist?(yaml_name)
309
+ puts "文件不存在:"+yaml_name
310
+ return nil
311
+ end
312
+
313
+ begin
314
+ yaml_content = YAML.load_file(yaml_name)
315
+ rescue Exception => e
316
+ puts e
317
+ puts yaml_name+'文件解析异常, 请检查 ⬆️'
318
+ exit!
319
+ end
320
+
321
+ unless yaml_content.class == Hash
322
+ puts "#{yaml_name} => (文件不是keyValue形式)"
323
+ return nil
324
+ end
325
+
326
+ yaml_content
349
327
  end
350
328
 
351
- def print_dependencies(yaml_dependencies)
352
- puts "➡️ 解析依赖总数共计:#{yaml_dependencies.size}个\n\n"
329
+ def print_yaml_deps
330
+ yaml_deps.each do |yaml_name, deps|
331
+ puts "读取#{yaml_name} => #{deps.size}个"
332
+ end
333
+ puts "➡️ 解析后依赖总数共计:#{all_deps.size}个\n"
334
+
353
335
  puts '⬇️ 打印依赖'
354
- yaml_dependencies.each_value { |dependency|
336
+ all_deps.each_value { |dependency|
355
337
  puts_result = "pod '#{dependency.pod}'"
356
338
 
357
339
  if dependency.path #路径引用
@@ -387,31 +369,13 @@ module Pod
387
369
  puts "⬆️ 打印完毕"
388
370
  end
389
371
 
390
- def local_yaml_contain(module_name)
391
- local_yaml_deps.include?(module_name)
392
- end
393
-
394
- # 是否需要快速编译
395
- def quick_build
396
-
397
- podfile_local_yaml = Constants::PODFILE_LOCAL_YAML
398
-
399
- unless File.exist?(podfile_local_yaml)
400
- puts "文件不存在:"+podfile_local_yaml
401
- return false
402
- end
403
-
404
- begin
405
- yaml_content = YAML.load_file(podfile_local_yaml)
406
- rescue Exception => e
407
- puts e
408
- return false
409
- end
410
-
411
- yaml_content["QUICKBUILD"] == true ? true : false
372
+ # 生成默认yaml文件
373
+ def generate_yaml
374
+ generate_local_yaml(podfile_local_yaml)
375
+ generate_module_yaml(podfile_module_yaml, "# 企业内部组件")
376
+ generate_module_yaml(podfile_third_party_yaml, "# 第三方维护组件")
412
377
  end
413
378
 
414
- # 生成local文件
415
379
  def generate_local_yaml(podfile_local_yaml)
416
380
  if File.exist?(podfile_local_yaml)
417
381
  return
@@ -423,8 +387,8 @@ module Pod
423
387
  content = content + "# 2、PODS下边的配置是数组形式, 如果有多个就写多个(subspecs需要数组)\n"
424
388
  content = content + "# 3、本文件加入到忽略文件中\n\n"
425
389
 
426
- # content = content + "# QUICKBUILD字段如果为true, 则表示会自动解析所有组件的依赖, 并删除不被使用的依赖库, 以达到开发时快速编译的目的\n"
427
- # content = content + "QUICKBUILD: false\n\n"
390
+ content = content + "# QUICK_BUILD字段如果为true, 则表示会自动解析所有组件的依赖, 并删除不被使用的依赖库, 以达到开发时快速编译的目的\n"
391
+ content = content + "QUICK_BUILD: false\n\n"
428
392
 
429
393
  content = content + "PODS:\n"
430
394
 
@@ -447,7 +411,6 @@ module Pod
447
411
  }
448
412
  end
449
413
 
450
- # 生成其他的yaml文件
451
414
  def generate_module_yaml(yaml_name, prefix)
452
415
  if File.exist?(yaml_name)
453
416
  return
@@ -457,16 +420,15 @@ module Pod
457
420
  content = ""
458
421
  content = content + prefix
459
422
  content = content + "\n"
460
- content = content + "# 1、优先级:path > podspec > version > tag > branch)\n"
423
+ content = content + "# 1、优先级:path > podspec > version > tag > branch\n"
461
424
  content = content + "# 2、path字段就是直接从对应的路径读取依赖\n"
462
425
  content = content + "# 3、podspec字段就是直接从对应的路径读取podspec文件加载依赖\n"
463
426
  content = content + "# 4、当version不为空时,会取source字段的repo获取组件,如果source字段为空,那么就取文件顶部配置的默认SOURCE\n"
464
427
  content = content + "# 5、当tag字段或branch字段不为空时,会取git字段的地址获取代码\n"
465
428
  content = content + "\n"
466
- content = content + "# 如果 source = null && binary = false 则source默认使用这个\n"
429
+ content = content + "# 如果 source = null && binary = false 则source默认使用SOURCE\n"
430
+ content = content + "# 如果 source = null && binary = true 则source默认使用BINARY_SOURCE\n"
467
431
  content = content + "SOURCE: 这里替换成源码的source\n"
468
- content = content + "\n"
469
- content = content + "# 如果 source = null && binary = true 则source默认使用这个\n"
470
432
  content = content + "BINARY_SOURCE: 这里替换成二进制的source\n"
471
433
  content = content + "\n"
472
434
  content = content + "PODS:\n"
@@ -489,5 +451,17 @@ module Pod
489
451
  }
490
452
  end
491
453
 
454
+ # 读取主工程target列表
455
+ def init_main_targets
456
+ project_manager = XCProject::XcodeprojManager.share_manager
457
+ @targets = project_manager.get_app_targets
458
+ end
459
+
460
+ #是否开启了编译优化开关
461
+ def quick_build
462
+ yaml_content = read_yaml_content(podfile_local_yaml)
463
+ !!(yaml_content["QUICK_BUILD"])
464
+ end
465
+
492
466
  end
493
467
  end