cocoapods-kz 0.0.2 → 0.0.4

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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-kz/command/install.rb +12 -9
  3. data/lib/cocoapods-kz/command/kz.rb +1 -0
  4. data/lib/cocoapods-kz/command/repair.rb +47 -0
  5. data/lib/cocoapods-kz/command/update.rb +12 -8
  6. data/lib/cocoapods-kz/gem_version.rb +1 -1
  7. data/lib/cocoapods-kz/helpers/kz_analyzer.rb +46 -3
  8. data/lib/cocoapods-kz/helpers/kz_framework_manager.rb +1 -1
  9. data/lib/cocoapods-kz/helpers/kz_generator.rb +256 -0
  10. data/lib/cocoapods-kz/helpers/kz_global_helper.rb +127 -0
  11. data/lib/cocoapods-kz/helpers/kz_pod_target.rb +95 -24
  12. data/lib/cocoapods-kz/helpers/repair_dynamic_swift.rb +373 -0
  13. data/lib/cocoapods-kz/helpers/repair_module_import.rb +113 -0
  14. data/lib/cocoapods-kz/native/acknowledgements.rb +8 -15
  15. data/lib/cocoapods-kz/native/analyzer.rb +5 -4
  16. data/lib/cocoapods-kz/native/dls.rb +2 -1
  17. data/lib/cocoapods-kz/native/file_accessor.rb +25 -8
  18. data/lib/cocoapods-kz/native/installer.rb +9 -22
  19. data/lib/cocoapods-kz/native/pod_target.rb +17 -0
  20. data/lib/cocoapods-kz/native/pod_target_installer.rb +30 -0
  21. data/lib/cocoapods-kz/native/target.rb +34 -0
  22. data/lib/cocoapods-kz/native/target_installer_helper.rb +105 -0
  23. data/lib/cocoapods-kz/native.rb +4 -1
  24. metadata +13 -10
  25. data/lib/cocoapods-kz/helpers/build_framework_config.rb +0 -48
  26. data/lib/cocoapods-kz/helpers/create_hamp.rb +0 -214
  27. data/lib/cocoapods-kz/helpers/global_helper.rb +0 -71
  28. data/lib/cocoapods-kz/helpers/strip_framework_config.rb +0 -40
  29. data/lib/cocoapods-kz/helpers/xml_build_config.rb +0 -53
  30. data/lib/cocoapods-kz/native/user_project_integrator.rb +0 -16
@@ -1,41 +1,61 @@
1
1
  require 'cocoapods'
2
2
  require 'fileutils'
3
- require_relative 'global_helper'
3
+ require 'weakref'
4
+ require_relative 'kz_global_helper'
4
5
 
5
6
  module KZ
7
+
6
8
  class KZPodTarget
7
9
 
8
10
  attr_reader :native_pod_target
9
11
  attr_reader :name
12
+ # 部分pod配置了subspec,此时获取的name为cocoapods处理之后的名字,可以通过root_name拿到pod本名
10
13
  attr_reader :root_name
11
- attr_reader :product_name
12
14
  attr_reader :version
15
+ # 当前target所有直接或间接依赖的target信息,是一个hash,key为target名字,value为KZPodTarget对象
13
16
  attr_accessor :dependent_target_info
17
+ # 所有通过kz_pod,:dependency手动配置的依赖target
14
18
  attr_accessor :repair_dependent_target_info
15
19
  attr_reader :repair_import
16
20
  attr_accessor :is_dev_pod
21
+ # target生成pod的模式,:kz_pod_origin_mode原始模式,也即代码模式,:kz_pod_code_mode代码模式,:kz_pod_framework_mod为framework模式
17
22
  attr_accessor :config_pod_mode
23
+ # pod kz install/update 中指定的pod模式,优先级最大
18
24
  attr_accessor :force_config_pod_mode
19
25
 
26
+ # 用于临时保存hamp过程的配置
20
27
  attr_accessor :private_header_search_path
21
28
  attr_accessor :repair_header_search_path
22
- attr_accessor :framwork_search_paths
29
+
30
+ # target编译最终的产物名称
31
+ attr_accessor :product_name
32
+ # 对应xcode配置PRODUCT_NAME,当多个target的PRODUCT_NAME相同时,需要手动修改,防止打包报错
33
+ attr_accessor :product_basename
34
+ # 当手动修改PRODUCT_NAME之后,@import需要修复为原使用方式
35
+ attr_accessor :repair_modulemap_path
36
+ # 当手动修改PRODUCT_NAME之后,#import<xx/xxx.h>需要修复为原使用方式,使用hmap进行映射
37
+ attr_accessor :need_repair_module_import
23
38
 
24
39
  def initialize(native_pod_target)
25
40
  @native_pod_target = native_pod_target
26
41
  @name = native_pod_target.name
27
42
  @root_name = native_pod_target.root_spec.name
28
- @product_name = native_pod_target.product_name
29
43
  @version = native_pod_target.version
30
44
  @dependent_target_info = {}
31
45
  @repair_dependent_target_info = {}
32
46
  @repair_import = []
33
- @isDevPod = false
47
+ @is_dev_pod = false
34
48
  @config_pod_mode = :kz_pod_origin_mode
35
49
 
50
+ @product_name = native_pod_target.origin_product_name
51
+ @product_basename = native_pod_target.origin_product_basename
52
+ @need_repair_module_import = false
53
+
36
54
  native_pod_target.file_accessors.each do |file_accessor|
37
55
  file_accessor.kz_pod_target = self
38
56
  end
57
+
58
+ native_pod_target.weakRef_kz_pod_target = WeakRef.new(self)
39
59
  end
40
60
 
41
61
  def uses_swift
@@ -47,7 +67,9 @@ module KZ
47
67
 
48
68
  all_headers = []
49
69
  native_pod_target.file_accessors.each do |file_accessor|
50
- all_headers.concat(file_accessor.headers)
70
+ next if file_accessor.spec.test_specification
71
+
72
+ all_headers.concat(file_accessor.kz_headers)
51
73
  end
52
74
 
53
75
  @_all_headers = all_headers
@@ -59,14 +81,16 @@ module KZ
59
81
 
60
82
  public_headers = []
61
83
  native_pod_target.file_accessors.each do |file_accessor|
62
- public_headers.concat(file_accessor.origin_public_headers)
63
- public_headers.concat(file_accessor.vendored_frameworks_headers)
84
+ next if file_accessor.spec.test_specification
85
+
86
+ public_headers.concat(file_accessor.kz_public_headers)
64
87
  end
65
88
 
66
89
  @_public_headers = public_headers
67
90
  @_public_headers
68
91
  end
69
92
 
93
+ # 重些config_pod_mode的set方法,kz_pod_framework_mode优先级最高
70
94
  def config_pod_mode=(value)
71
95
  return if value == :kz_pod_origin_mode
72
96
 
@@ -79,12 +103,14 @@ module KZ
79
103
  end
80
104
  end
81
105
 
106
+ # 重些config_pod_mode的get方法,force_config_pod_mode优先级最高
82
107
  def config_pod_mode
83
108
  return @force_config_pod_mode if @force_config_pod_mode != :kz_pod_origin_mode
84
109
 
85
110
  @config_pod_mode
86
111
  end
87
112
 
113
+ # 配合kz_pod对target进行配置
88
114
  def add_kz_pod_config(pod_config)
89
115
  return unless pod_config
90
116
 
@@ -93,6 +119,12 @@ module KZ
93
119
  repair_dependency.each { |repair_dependent_pod_target_name|
94
120
  kz_repair_pod_target = yield(repair_dependent_pod_target_name)
95
121
  if kz_repair_pod_target
122
+ native_dependent_targets_by_config = self.native_pod_target.dependent_targets_by_config
123
+ native_dependent_targets_by_config.each do |_, dependent_targets|
124
+ dependent_targets << kz_repair_pod_target.native_pod_target
125
+ end
126
+ self.native_pod_target.dependent_targets_by_config = native_dependent_targets_by_config
127
+
96
128
  @dependent_target_info[repair_dependent_pod_target_name] = kz_repair_pod_target
97
129
  @repair_dependent_target_info[repair_dependent_pod_target_name] = kz_repair_pod_target
98
130
  end
@@ -110,6 +142,7 @@ module KZ
110
142
  end
111
143
  end
112
144
 
145
+ # 在当前target的所有依赖中,过滤有有修补的target
113
146
  def all_need_repair_import
114
147
  all_need_repair_import = []
115
148
 
@@ -119,6 +152,7 @@ module KZ
119
152
  all_need_repair_import.uniq
120
153
  end
121
154
 
155
+ # 获取当前target所有依赖,包括手动补充的
122
156
  def recursive_dependent_targets
123
157
  recursive_dependent_targets = []
124
158
  @dependent_target_info.values.each do |dependent_target|
@@ -131,11 +165,10 @@ module KZ
131
165
  recursive_dependent_targets
132
166
  end
133
167
 
168
+ # 直接用于配置HEADER_SEARCH_PATHS
134
169
  def header_search_paths
135
170
  header_search_paths = ''
136
- if @private_header_search_path && File.exist?(@private_header_search_path)
137
- header_search_paths = @private_header_search_path.to_s
138
- end
171
+ header_search_paths = KZ.deal_path_for_xcconfig(@private_header_search_path, true) if @private_header_search_path
139
172
  repair_header_search_paths = self.all_repair_header_search_paths.join(' ')
140
173
  if repair_header_search_paths.length > 0
141
174
  header_search_paths += (' ' + repair_header_search_paths)
@@ -143,6 +176,19 @@ module KZ
143
176
  header_search_paths
144
177
  end
145
178
 
179
+ # 获取当前target所有需要修补target的hmap
180
+ def all_repair_header_search_paths
181
+ all_repair_header_search_paths = []
182
+ all_repair_header_search_paths << KZ.deal_path_for_xcconfig(@repair_header_search_path, true) if @repair_header_search_path
183
+ self.all_need_repair_import.each do |need_repair_target|
184
+ sub_repair_header_search_path = need_repair_target.repair_header_search_path
185
+ all_repair_header_search_paths << KZ.deal_path_for_xcconfig(sub_repair_header_search_path, true) if sub_repair_header_search_path
186
+ end
187
+ all_repair_header_search_paths.uniq
188
+ end
189
+
190
+ # 参考@repair_dependent_target_info,获取所有当前target直接或间接配置的依赖target
191
+ # 用于配置FRAMEWORK_SEARCH_PATHS内容
146
192
  def all_repair_dependent_target_info
147
193
  all_repair_dependent_target_info = @repair_dependent_target_info
148
194
  @dependent_target_info.values.each do |dependent_target|
@@ -151,23 +197,48 @@ module KZ
151
197
  all_repair_dependent_target_info
152
198
  end
153
199
 
154
- def all_repair_header_search_paths
155
- all_repair_header_search_paths = []
156
- if @repair_header_search_path && File.exist?(@repair_header_search_path)
157
- all_repair_header_search_paths << @repair_header_search_path.to_s
200
+ # 获取target对应的配置根目录,部分文件需要依赖版本进行存储
201
+ def pod_config_cache_path(concat_version)
202
+ kz_target_framework_folder = KZ_POD_CONFIG_ROOT + @name
203
+ kz_target_framework_folder += @version if concat_version
204
+ FileUtils.mkdir_p(kz_target_framework_folder) unless File.exist?(kz_target_framework_folder) || concat_version
205
+ kz_target_framework_folder
206
+ end
207
+
208
+ # 获取target中的module name,默认为product_module_name与target.name也相同。
209
+ # 部分target导入的framework名字与modulemap中的名字不对应,需要特殊处理
210
+ # eg.AMapSearch,product_module_name为AMapSearch,modulemap中的名字为AMapSearchKit
211
+ def kz_module_name
212
+ return @native_pod_target.product_module_name unless all_headers.count > 0
213
+
214
+ one_header_path = all_headers.first.to_s
215
+ if one_header_path.include?('.framework')
216
+ one_header_path.split('/').each do |name|
217
+ if name.include?('.framework')
218
+ return name.split('.').first
219
+ end
220
+ end
158
221
  end
159
- self.all_need_repair_import.each do |need_repair_target|
160
- sub_repair_header_search_path = need_repair_target.repair_header_search_path
161
- all_repair_header_search_paths << sub_repair_header_search_path if sub_repair_header_search_path
222
+ return @native_pod_target.product_module_name
223
+ end
224
+
225
+ # 获取所有用于修复的modulemap路径,原因参考@repair_modulemap_path
226
+ def all_repair_modulemap_paths
227
+ all_repair_modulemap_paths = []
228
+ all_repair_modulemap_paths << repair_modulemap_path if self.repair_modulemap_path
229
+ recursive_dependent_targets.each do |recursive_dependent_target|
230
+ all_repair_modulemap_paths.concat(recursive_dependent_target.all_repair_modulemap_paths)
162
231
  end
163
- all_repair_header_search_paths.uniq
232
+ all_repair_modulemap_paths.uniq! if all_repair_modulemap_paths.count > 0
233
+ all_repair_modulemap_paths
164
234
  end
165
235
 
166
- def pod_config_cache_path(concat_version)
167
- kz_target_framework_folder = KZ_POD_CONFIG_ROOT + @name
168
- kz_target_framework_folder += @version if concat_version
169
- FileUtils.mkdir_p(kz_target_framework_folder) unless File.exist?(kz_target_framework_folder)
170
- Pathname(kz_target_framework_folder)
236
+ def prefix_header_path
237
+ @native_pod_target.prefix_header_path
238
+ end
239
+
240
+ def should_build?
241
+ @native_pod_target.should_build?
171
242
  end
172
243
 
173
244
  end
@@ -0,0 +1,373 @@
1
+ require_relative 'kz_global_helper'
2
+
3
+ module KZ
4
+ class KZSwiftContext
5
+ def initialize(type_contexts)
6
+ @type_contexts = type_contexts
7
+ @type_ornament = []
8
+ @type_header = []
9
+ @type_str = ""
10
+ @type_body = []
11
+
12
+ if @type_contexts.length == 1
13
+ element = @type_contexts[0]
14
+ puts @type_contexts
15
+ @type_ornament = element.scan(/@\w+[()\w\n]*/)
16
+ element_info = element.split("{")
17
+ @type_str = element_info[0] + "{"
18
+ @type_body << element_info[1].sub("}", "")
19
+ else
20
+ # 1 从未扫描到class 2 扫描到class 3 class扫描完毕
21
+ type_line_tag = 1
22
+ type_lines = []
23
+ for type_line in @type_contexts
24
+ if type_line_tag == 1
25
+ ornaments = type_line.scan(/@\w+[()\w\n]*/)
26
+ @type_ornament.concat(ornaments) if ornaments.length > 0
27
+
28
+ result = yield(type_line)
29
+ if result
30
+ type_line_tag = 2
31
+ else
32
+ @type_header << type_line
33
+ next
34
+ end
35
+ end
36
+
37
+ if type_line_tag == 2
38
+ type_lines << type_line
39
+ if type_line.include?("{")
40
+ type_line_tag = 3
41
+ @type_str = type_lines.join("")
42
+ end
43
+ next
44
+ end
45
+
46
+ @type_body << type_line
47
+ end
48
+
49
+ last_element = @type_body[-1]
50
+ @type_body.pop()
51
+ @type_body << last_element.sub("}", "")
52
+ end
53
+ end
54
+
55
+ def get_oc_feature_contexts
56
+ @type_contexts
57
+ end
58
+
59
+ end
60
+
61
+ class KZSwiftParagraph < KZSwiftContext
62
+
63
+ def initialize(type_contexts, need_handle_func)
64
+ @type_contexts = type_contexts
65
+ @need_handle_func = need_handle_func
66
+ end
67
+
68
+ def get_oc_feature_contexts
69
+ if @need_handle_func
70
+ new_class_context = []
71
+
72
+ for context in @type_contexts
73
+ if context.include?("init()") && !context.include?("override")
74
+ context = context.sub("init()", "override init()")
75
+ context = context.sub("{", "{\nsuper.init()")
76
+ end
77
+ new_class_context << context
78
+ end
79
+ return new_class_context
80
+ else
81
+ return @type_contexts
82
+ end
83
+ end
84
+ end
85
+
86
+ class KZSwiftClass < KZSwiftContext
87
+
88
+ def initialize(type_contexts)
89
+ @system_nsobject_class = [
90
+ "NSObject"
91
+ ]
92
+
93
+ super(type_contexts) do |line|
94
+ KZSwiftClass.check_line_have_class_tag(line)
95
+ end
96
+ end
97
+
98
+ def self.check_line_have_class_tag(line)
99
+ if line =~ /^(?:.*\s)?class\s/ && !line.include?("func") && !line.include?("var") && !line.include?("let")
100
+ return true
101
+ else
102
+ return false
103
+ end
104
+ end
105
+
106
+ def get_oc_feature_contexts
107
+ new_class_context = []
108
+
109
+ # 获取类、父类、协议信息
110
+ class_name = ""
111
+ superClass_and_protocol = []
112
+
113
+ class_line = @type_str.gsub(/\s+/, "")
114
+ class_line = class_line.split("class")[1]
115
+ if class_line.include?(":")
116
+ colon_infos = class_line.split(":")
117
+ class_name = colon_infos[0]
118
+
119
+ colon_right = colon_infos[1]
120
+ colon_right = colon_right.sub("{", "")
121
+ superClass_and_protocol = colon_right.split(",")
122
+ else
123
+ class_name = class_line.sub("{", "")
124
+ end
125
+
126
+ return @type_contexts if class_name == ""
127
+
128
+ # 获取oc特性标识
129
+ have_super_class = false
130
+ if superClass_and_protocol.length > 0
131
+ have_super_class = !superClass_and_protocol[0].end_with?("Protocol")
132
+ end
133
+
134
+ have_objc_class = false
135
+ have_objc_members = false
136
+ for ornament in @type_ornament
137
+ if ornament.start_with?("@objc ") || ornament.start_with?("@objc(") || ornament == "@objc" || ornament == "@objc\n"
138
+ have_objc_class = true
139
+ end
140
+ have_objc_members = true if ornament.start_with?("@objcMembers")
141
+ end
142
+
143
+ # 添加class ornament
144
+ new_class_context.concat(@type_header)
145
+
146
+ if !have_objc_members
147
+ new_class_context.insert(0, "@objcMembers\n")
148
+ end
149
+
150
+ if !have_objc_class && !have_super_class
151
+ new_class_context.insert(0, "@objc\n")
152
+ end
153
+
154
+ # 添加class header
155
+ if !have_objc_class && !have_super_class
156
+ if superClass_and_protocol.length > 0
157
+ if !@system_nsobject_class.include?(superClass_and_protocol[0])
158
+ @type_str = @type_str.sub(":", ": NSObject,")
159
+ end
160
+ else
161
+ @type_str = @type_str.sub("{", ": NSObject {")
162
+ end
163
+ end
164
+ new_class_context << @type_str
165
+
166
+ # 添加class body
167
+ new_swift_types = KZSwiftFileAnalyse.analyse_swift_file(@type_body, !have_super_class)
168
+ new_swift_types.each do |swift_type|
169
+ new_class_context.concat(swift_type.get_oc_feature_contexts())
170
+ end
171
+ new_class_context << "}\n"
172
+
173
+ new_class_context
174
+ end
175
+ end
176
+
177
+ class KZSwiftEnum < KZSwiftContext
178
+
179
+ def initialize(type_contexts)
180
+ super(type_contexts) do |line|
181
+ return KZSwiftEnum.check_line_have_enum_tag(line)
182
+ end
183
+ end
184
+
185
+ def self.check_line_have_enum_tag(line)
186
+ if line =~ /^(?:.*\s)?enum\s/
187
+ return true
188
+ else
189
+ return false
190
+ end
191
+ end
192
+
193
+ def get_oc_feature_contexts
194
+ new_enum_context = []
195
+
196
+ have_objc_tag = false
197
+ for ornament in @type_ornament
198
+ if ornament.start_with?("@objc ") || ornament.start_with?("@objc(") || ornament == "@objc"
199
+ have_objc_tag = true
200
+ end
201
+ end
202
+
203
+ return @type_contexts if have_objc_tag
204
+
205
+ for enum_line in @type_contexts
206
+ if KZSwiftEnum.check_line_have_enum_tag(enum_line)
207
+ raw_value_type = ""
208
+ raw_value_type = $1 if enum_line =~ /^.*:\s*(\w+)\s*{/
209
+
210
+ if raw_value_type == "Int"
211
+ new_enum_context.insert(0, "@objc\n")
212
+ else
213
+ return @type_contexts
214
+ end
215
+ end
216
+ new_enum_context << enum_line
217
+ end
218
+
219
+ new_enum_context
220
+ end
221
+ end
222
+
223
+ class KZSwiftFileAnalyse
224
+ def self.analyse_swift_file(swift_files, need_handle_func)
225
+ swift_types = []
226
+
227
+ cursor_index = 0
228
+ swift_files.each_with_index do |line, index|
229
+ next if line.start_with?("//")
230
+ next if index < cursor_index
231
+
232
+ if KZSwiftClass.check_line_have_class_tag(line)
233
+ class_begin_line = find_type_begin_index(index, cursor_index, swift_files)
234
+ class_end_line = find_type_end_index(index, swift_files)
235
+
236
+ # 封装无关代码
237
+ if class_begin_line > cursor_index
238
+ contexts = swift_files[cursor_index...class_begin_line]
239
+ swift_types << KZSwiftParagraph.new(contexts, need_handle_func)
240
+ end
241
+
242
+ # 封装类代码
243
+ contexts = swift_files[class_begin_line..class_end_line]
244
+ swift_types << KZSwiftClass.new(contexts)
245
+
246
+ # 更新游标
247
+ cursor_index = class_end_line + 1
248
+ elsif KZSwiftEnum.check_line_have_enum_tag(line)
249
+ enum_begin_line = find_type_begin_index(index, cursor_index, swift_files)
250
+ enum_end_line = find_type_end_index(index, swift_files)
251
+
252
+ # 封装无关代码
253
+ if enum_begin_line > cursor_index
254
+ contexts = swift_files[cursor_index...enum_begin_line]
255
+ swift_types << KZSwiftParagraph.new(contexts, need_handle_func)
256
+ end
257
+
258
+ # 封装枚举代码
259
+ contexts = swift_files[enum_begin_line..enum_end_line]
260
+ swift_types << KZSwiftEnum.new(contexts)
261
+
262
+ # 更新游标
263
+ cursor_index = enum_end_line + 1
264
+ end
265
+ end
266
+
267
+ # 封装无关代码
268
+ if cursor_index < swift_files.length
269
+ contexts = swift_files[cursor_index...swift_files.length]
270
+ swift_types << KZSwiftParagraph.new(contexts, need_handle_func)
271
+ end
272
+
273
+ swift_types
274
+ end
275
+
276
+ def self.find_type_begin_index(current_index, cursor_index, swift_files)
277
+ class_begin_line = current_index
278
+ if current_index > 0
279
+ (cursor_index...current_index).reverse_each do |_index|
280
+ previous_line = swift_files[_index].lstrip
281
+
282
+ next if previous_line == ""
283
+
284
+ if previous_line.start_with?("@")
285
+ class_begin_line = _index
286
+ else
287
+ break
288
+ end
289
+ end
290
+ end
291
+ class_begin_line
292
+ end
293
+
294
+ def self.find_type_end_index(current_index, swift_files)
295
+ class_end_line = current_index
296
+ if current_index < swift_files.length
297
+ left_bracket_count = -1
298
+ (current_index...swift_files.length).each do |_index|
299
+ next_line = swift_files[_index]
300
+
301
+ left_brackets = next_line.scan(/{/)
302
+ right_brackets = next_line.scan(/}/)
303
+
304
+ if left_brackets.length > 0
305
+ left_bracket_count = 0 if left_bracket_count == -1
306
+ left_bracket_count += left_brackets.length
307
+ end
308
+
309
+ if right_brackets.length > 0
310
+ left_bracket_count -= right_brackets.length
311
+
312
+ if left_bracket_count == 0
313
+ class_end_line = _index
314
+ break
315
+ end
316
+ end
317
+ end
318
+ end
319
+ class_end_line
320
+ end
321
+ end
322
+
323
+ class KZSwiftAttachOCFeature
324
+
325
+ def initialize
326
+ @all_kz_pod_targets = KZ::KZGlobalHelper.instance.kz_analyzer.all_kz_pod_targets
327
+ @specify_pod_names = KZ::KZGlobalHelper.instance.specify_pod_names
328
+ end
329
+
330
+ def repair
331
+ @all_kz_pod_targets.values.each do |kz_pod_target|
332
+ next unless kz_pod_target.is_dev_pod
333
+ next if @specify_pod_names.count > 0 && !@specify_pod_names.include?(kz_pod_target.name)
334
+
335
+ need_repair_files = []
336
+ kz_pod_target.native_pod_target.file_accessors.each do |file_accessor|
337
+ next if file_accessor.spec.test_specification
338
+
339
+ file_accessor.origin_source_files.each do |source_file|
340
+ if source_file.extname == ".swift"
341
+ need_repair_files << source_file
342
+ end
343
+ end
344
+ end
345
+
346
+ puts "Start reair '#{kz_pod_target.name}' swfit files..."
347
+ need_repair_files.each do |swift_file_path|
348
+ swift_file = File.open(swift_file_path, 'r')
349
+ swift_files = swift_file.readlines
350
+ swift_file.close
351
+ swift_types = KZSwiftFileAnalyse.analyse_swift_file(swift_files, false)
352
+
353
+ new_swift_contexts = []
354
+ swift_types.each do |swift_type|
355
+ new_swift_contexts.concat(swift_type.get_oc_feature_contexts())
356
+ end
357
+ # puts new_swift_contexts
358
+ write_swift_file(swift_file_path, new_swift_contexts)
359
+ end
360
+ end
361
+
362
+ end
363
+
364
+ def write_swift_file(file_path, contexts)
365
+ swift_file = File.open(file_path, 'w')
366
+ contexts.each do |new_line|
367
+ swift_file.write(new_line)
368
+ end
369
+ swift_file.close
370
+ end
371
+
372
+ end
373
+ end