cocoapods-kz 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-kz/command/install.rb +7 -6
  3. data/lib/cocoapods-kz/command/repair.rb +2 -2
  4. data/lib/cocoapods-kz/command/update.rb +7 -6
  5. data/lib/cocoapods-kz/gem_version.rb +1 -1
  6. data/lib/cocoapods-kz/helpers/kz_analyzer.rb +41 -4
  7. data/lib/cocoapods-kz/helpers/kz_framework_manager.rb +1 -1
  8. data/lib/cocoapods-kz/helpers/kz_generator.rb +268 -0
  9. data/lib/cocoapods-kz/helpers/{global_helper.rb → kz_global_helper.rb} +30 -6
  10. data/lib/cocoapods-kz/helpers/kz_pod_target.rb +76 -22
  11. data/lib/cocoapods-kz/helpers/repair_dynamic_swift.rb +2 -2
  12. data/lib/cocoapods-kz/helpers/repair_module_import.rb +16 -25
  13. data/lib/cocoapods-kz/native/analyzer.rb +4 -1
  14. data/lib/cocoapods-kz/native/dls.rb +2 -1
  15. data/lib/cocoapods-kz/native/file_accessor.rb +17 -0
  16. data/lib/cocoapods-kz/native/installer.rb +9 -24
  17. data/lib/cocoapods-kz/native/pod_target.rb +17 -0
  18. data/lib/cocoapods-kz/native/pod_target_installer.rb +30 -0
  19. data/lib/cocoapods-kz/native/specification.rb +31 -0
  20. data/lib/cocoapods-kz/native/target.rb +34 -0
  21. data/lib/cocoapods-kz/native/target_installer_helper.rb +125 -0
  22. data/lib/cocoapods-kz/native.rb +6 -2
  23. data/lib/cocoapods-kz/resources/kz_merge_swift_h.rb +14 -0
  24. metadata +10 -8
  25. data/lib/cocoapods-kz/helpers/build_framework_config.rb +0 -53
  26. data/lib/cocoapods-kz/helpers/create_hamp.rb +0 -236
  27. data/lib/cocoapods-kz/helpers/strip_framework_config.rb +0 -40
  28. data/lib/cocoapods-kz/helpers/xml_build_config.rb +0 -57
  29. data/lib/cocoapods-kz/native/user_project_integrator.rb +0 -16
@@ -1,31 +1,45 @@
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 = {}
@@ -33,9 +47,15 @@ module KZ
33
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
@@ -49,7 +69,7 @@ module KZ
49
69
  native_pod_target.file_accessors.each do |file_accessor|
50
70
  next if file_accessor.spec.test_specification
51
71
 
52
- all_headers.concat(file_accessor.headers)
72
+ all_headers.concat(file_accessor.kz_headers)
53
73
  end
54
74
 
55
75
  @_all_headers = all_headers
@@ -63,13 +83,14 @@ module KZ
63
83
  native_pod_target.file_accessors.each do |file_accessor|
64
84
  next if file_accessor.spec.test_specification
65
85
 
66
- public_headers.concat(file_accessor.origin_public_headers)
86
+ public_headers.concat(file_accessor.kz_public_headers)
67
87
  end
68
88
 
69
89
  @_public_headers = public_headers
70
90
  @_public_headers
71
91
  end
72
92
 
93
+ # 重些config_pod_mode的set方法,kz_pod_framework_mode优先级最高
73
94
  def config_pod_mode=(value)
74
95
  return if value == :kz_pod_origin_mode
75
96
 
@@ -82,12 +103,14 @@ module KZ
82
103
  end
83
104
  end
84
105
 
106
+ # 重些config_pod_mode的get方法,force_config_pod_mode优先级最高
85
107
  def config_pod_mode
86
108
  return @force_config_pod_mode if @force_config_pod_mode != :kz_pod_origin_mode
87
109
 
88
110
  @config_pod_mode
89
111
  end
90
112
 
113
+ # 配合kz_pod对target进行配置
91
114
  def add_kz_pod_config(pod_config)
92
115
  return unless pod_config
93
116
 
@@ -96,6 +119,12 @@ module KZ
96
119
  repair_dependency.each { |repair_dependent_pod_target_name|
97
120
  kz_repair_pod_target = yield(repair_dependent_pod_target_name)
98
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
+
99
128
  @dependent_target_info[repair_dependent_pod_target_name] = kz_repair_pod_target
100
129
  @repair_dependent_target_info[repair_dependent_pod_target_name] = kz_repair_pod_target
101
130
  end
@@ -113,6 +142,7 @@ module KZ
113
142
  end
114
143
  end
115
144
 
145
+ # 在当前target的所有依赖中,过滤有有修补的target
116
146
  def all_need_repair_import
117
147
  all_need_repair_import = []
118
148
 
@@ -122,6 +152,7 @@ module KZ
122
152
  all_need_repair_import.uniq
123
153
  end
124
154
 
155
+ # 获取当前target所有依赖,包括手动补充的
125
156
  def recursive_dependent_targets
126
157
  recursive_dependent_targets = []
127
158
  @dependent_target_info.values.each do |dependent_target|
@@ -134,11 +165,10 @@ module KZ
134
165
  recursive_dependent_targets
135
166
  end
136
167
 
168
+ # 直接用于配置HEADER_SEARCH_PATHS
137
169
  def header_search_paths
138
170
  header_search_paths = ''
139
- if @private_header_search_path && File.exist?(@private_header_search_path)
140
- header_search_paths = @private_header_search_path.to_s
141
- end
171
+ header_search_paths = KZ.deal_path_for_xcconfig(@private_header_search_path, true) if @private_header_search_path
142
172
  repair_header_search_paths = self.all_repair_header_search_paths.join(' ')
143
173
  if repair_header_search_paths.length > 0
144
174
  header_search_paths += (' ' + repair_header_search_paths)
@@ -146,33 +176,38 @@ module KZ
146
176
  header_search_paths
147
177
  end
148
178
 
149
- def all_repair_dependent_target_info
150
- all_repair_dependent_target_info = @repair_dependent_target_info
151
- @dependent_target_info.values.each do |dependent_target|
152
- all_repair_dependent_target_info.merge!(dependent_target.all_repair_dependent_target_info)
153
- end
154
- all_repair_dependent_target_info
155
- end
156
-
179
+ # 获取当前target所有需要修补target的hmap
157
180
  def all_repair_header_search_paths
158
181
  all_repair_header_search_paths = []
159
- if @repair_header_search_path && File.exist?(@repair_header_search_path)
160
- all_repair_header_search_paths << @repair_header_search_path.to_s
161
- end
182
+ all_repair_header_search_paths << KZ.deal_path_for_xcconfig(@repair_header_search_path, true) if @repair_header_search_path
162
183
  self.all_need_repair_import.each do |need_repair_target|
163
184
  sub_repair_header_search_path = need_repair_target.repair_header_search_path
164
- all_repair_header_search_paths << sub_repair_header_search_path if sub_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
165
186
  end
166
187
  all_repair_header_search_paths.uniq
167
188
  end
168
189
 
190
+ # 参考@repair_dependent_target_info,获取所有当前target直接或间接配置的依赖target
191
+ # 用于配置FRAMEWORK_SEARCH_PATHS内容
192
+ def all_repair_dependent_target_info
193
+ all_repair_dependent_target_info = @repair_dependent_target_info
194
+ @dependent_target_info.values.each do |dependent_target|
195
+ all_repair_dependent_target_info.merge!(dependent_target.all_repair_dependent_target_info)
196
+ end
197
+ all_repair_dependent_target_info
198
+ end
199
+
200
+ # 获取target对应的配置根目录,部分文件需要依赖版本进行存储
169
201
  def pod_config_cache_path(concat_version)
170
202
  kz_target_framework_folder = KZ_POD_CONFIG_ROOT + @name
171
203
  kz_target_framework_folder += @version if concat_version
172
204
  FileUtils.mkdir_p(kz_target_framework_folder) unless File.exist?(kz_target_framework_folder) || concat_version
173
- Pathname(kz_target_framework_folder)
205
+ kz_target_framework_folder
174
206
  end
175
207
 
208
+ # 获取target中的module name,默认为product_module_name与target.name也相同。
209
+ # 部分target导入的framework名字与modulemap中的名字不对应,需要特殊处理
210
+ # eg.AMapSearch,product_module_name为AMapSearch,modulemap中的名字为AMapSearchKit
176
211
  def kz_module_name
177
212
  return @native_pod_target.product_module_name unless all_headers.count > 0
178
213
 
@@ -187,5 +222,24 @@ module KZ
187
222
  return @native_pod_target.product_module_name
188
223
  end
189
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)
231
+ end
232
+ all_repair_modulemap_paths.uniq! if all_repair_modulemap_paths.count > 0
233
+ all_repair_modulemap_paths
234
+ end
235
+
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?
242
+ end
243
+
190
244
  end
191
245
  end
@@ -1,4 +1,4 @@
1
- require_relative 'global_helper'
1
+ require_relative 'kz_global_helper'
2
2
 
3
3
  module KZ
4
4
  class KZSwiftContext
@@ -336,7 +336,7 @@ module KZ
336
336
  kz_pod_target.native_pod_target.file_accessors.each do |file_accessor|
337
337
  next if file_accessor.spec.test_specification
338
338
 
339
- file_accessor.source_files.each do |source_file|
339
+ file_accessor.origin_source_files.each do |source_file|
340
340
  if source_file.extname == ".swift"
341
341
  need_repair_files << source_file
342
342
  end
@@ -1,4 +1,4 @@
1
- require_relative 'global_helper'
1
+ require_relative 'kz_global_helper'
2
2
 
3
3
  module KZ
4
4
  class KZRepairModuleImport
@@ -9,7 +9,7 @@ module KZ
9
9
  end
10
10
 
11
11
  def repair
12
- if @specify_pod_names.count == 0
12
+ if @specify_pod_names.count == 0 || @specify_pod_names.include?("Main")
13
13
  main_project_file_folder = @main_project.project_dir + @main_project.root_object.display_name
14
14
  main_project_files = []
15
15
  main_project_headers = []
@@ -27,35 +27,26 @@ module KZ
27
27
  main_project_files.each do |file_path|
28
28
  repair_file(file_path, main_project_headers)
29
29
  end
30
+ end
30
31
 
31
- @all_kz_pod_targets.values.each do |kz_pod_target|
32
- next unless kz_pod_target.is_dev_pod
33
-
34
- puts "Start reair '#{kz_pod_target.name}' header files..."
35
- kz_pod_target.all_headers.each do |header_path|
36
- repair_file(header_path, kz_pod_target.all_headers, kz_pod_target.recursive_dependent_targets)
37
- end
38
- end
39
- else
40
- @all_kz_pod_targets.values.each do |kz_pod_target|
41
- next unless kz_pod_target.is_dev_pod
42
- next unless @specify_pod_names.include?(kz_pod_target.name)
32
+ @all_kz_pod_targets.values.each do |kz_pod_target|
33
+ next unless kz_pod_target.is_dev_pod
34
+ next unless @specify_pod_names.count > 0 && @specify_pod_names.include?(kz_pod_target.name)
43
35
 
44
- need_repair_files = []
45
- kz_pod_target.native_pod_target.file_accessors.each do |file_accessor|
46
- next if file_accessor.spec.test_specification
36
+ need_repair_files = []
37
+ kz_pod_target.native_pod_target.file_accessors.each do |file_accessor|
38
+ next if file_accessor.spec.test_specification
47
39
 
48
- file_accessor.source_files.each do |source_file|
49
- if [".h", ".m", ".mm"].include?(source_file.extname)
50
- need_repair_files << source_file
51
- end
40
+ file_accessor.source_files.each do |source_file|
41
+ if %w[.h .m .mm].include?(source_file.extname)
42
+ need_repair_files << source_file
52
43
  end
53
44
  end
45
+ end
54
46
 
55
- puts "Start reair '#{kz_pod_target.name}' files..."
56
- need_repair_files.each do |file_path|
57
- repair_file(file_path, kz_pod_target.all_headers, kz_pod_target.recursive_dependent_targets)
58
- end
47
+ puts "Start reair '#{kz_pod_target.name}' files..."
48
+ need_repair_files.each do |file_path|
49
+ repair_file(file_path, kz_pod_target.all_headers, kz_pod_target.recursive_dependent_targets)
59
50
  end
60
51
  end
61
52
  end
@@ -1,4 +1,5 @@
1
- require 'cocoapods-kz/helpers/global_helper'
1
+ require 'cocoapods-kz/helpers/kz_global_helper'
2
+ require 'cocoapods-kz/helpers/kz_generator'
2
3
 
3
4
  module Pod
4
5
  class Installer
@@ -8,9 +9,11 @@ module Pod
8
9
  def generate_targets(resolver_specs_by_target, target_inspections)
9
10
  aggregate_targets, pod_targets = original_generate_targets(resolver_specs_by_target, target_inspections)
10
11
  if KZ::KZGlobalHelper.instance.generate_kz_pod_targets
12
+ main_project = aggregate_targets.first.user_project
11
13
  kz_analyer = KZ::KZAnalyzer.new(pod_targets, self.sandbox.development_pods)
12
14
  kz_analyer.analyer
13
15
  KZ::KZGlobalHelper.instance.kz_analyzer = kz_analyer
16
+ KZ::KZGlobalHelper.instance.kz_generator = KZ::KZGenerator.new(main_project)
14
17
  end
15
18
  [aggregate_targets, pod_targets]
16
19
  end
@@ -1,8 +1,9 @@
1
- require 'cocoapods-kz/helpers/global_helper'
1
+ require 'cocoapods-kz/helpers/kz_global_helper'
2
2
 
3
3
  module Pod
4
4
  class Podfile
5
5
  module DSL
6
+
6
7
  KZ::KZGlobalHelper.instance.kz_pod_config ||= {}
7
8
 
8
9
  def kz_pod(name = nil, *requirements)
@@ -82,6 +82,23 @@ module Pod
82
82
  end
83
83
  end
84
84
 
85
+ def kz_headers
86
+ extensions = HEADER_EXTENSIONS
87
+ origin_source_files.select { |f| extensions.include?(f.extname) }
88
+ end
89
+
90
+ def kz_public_headers
91
+ public_headers = public_header_files
92
+ project_headers = project_header_files
93
+ private_headers = private_header_files
94
+ if public_headers.nil? || public_headers.empty?
95
+ header_files = kz_headers
96
+ else
97
+ header_files = public_headers
98
+ end
99
+ header_files - project_headers - private_headers
100
+ end
101
+
85
102
  end
86
103
  end
87
104
  end
@@ -1,37 +1,22 @@
1
1
  require 'cocoapods/installer'
2
- require 'cocoapods-kz/helpers/xml_build_config'
3
- require 'cocoapods-kz/helpers/strip_framework_config'
4
- require 'cocoapods-kz/helpers/build_framework_config'
5
- require 'cocoapods-kz/helpers/create_hamp'
6
2
 
7
3
  module Pod
8
4
  class Installer
9
5
  alias_method :original_integrate_user_project, :integrate_user_project
10
6
  def integrate_user_project
11
7
  original_integrate_user_project
12
-
13
8
  if KZ::KZGlobalHelper.instance.kz_pod_enable
14
- main_project = self.aggregate_targets.first.user_project
15
- pods_project = self.pods_project
16
-
17
- puts 'Start KZPlugin Config'
18
- if KZ::KZGlobalHelper.instance.have_flexLib_pod_target
19
- KZ::XmlBuildConfig.new(main_project, pods_project).config_project
20
- end
21
-
22
- KZ::StripFrameworkConfig.new(main_project, pods_project).config_project
23
-
24
- unless KZ::KZGlobalHelper.instance.disable_generate_framework
25
- KZ::BuildFrameworkConfig.new(main_project, pods_project).config_project
26
- end
27
-
28
- KZ::CreateHmap.new(main_project, pods_project).config_project
29
-
30
- main_project.save
31
- pods_project.save
32
-
33
9
  KZ::KZGlobalHelper.instance.write_lock_file
34
10
  end
35
11
  end
12
+
13
+ alias_method :original_integrate, :integrate
14
+ def integrate
15
+ if KZ::KZGlobalHelper.instance.kz_pod_enable
16
+ # hmap的创建需要在download之后,integrate之前
17
+ KZ::KZGlobalHelper.instance.kz_generator.create_hamp
18
+ end
19
+ original_integrate
20
+ end
36
21
  end
37
22
  end
@@ -0,0 +1,17 @@
1
+
2
+ module Pod
3
+ class PodTarget < Target
4
+
5
+ def dependent_targets_by_config=(dependent_targets_by_config)
6
+ @dependent_targets_by_config = dependent_targets_by_config
7
+ @dependent_targets = dependent_targets_by_config.each_value.reduce([], &:|)
8
+
9
+ # 让@recursive_dependent_targets重新赋值
10
+ if defined?(@recursive_dependent_targets)
11
+ @recursive_dependent_targets = nil
12
+ remove_instance_variable(:@recursive_dependent_targets)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+
2
+ module Pod
3
+ class Installer
4
+ class Xcode
5
+ class PodsProjectGenerator
6
+
7
+ class PodTargetInstaller < TargetInstaller
8
+ require 'cocoapods/installer/xcode/pods_project_generator/app_host_installer'
9
+
10
+ alias_method :origin_install!, :install!
11
+ def install!
12
+ target_installation_result = origin_install!
13
+ if KZ::KZGlobalHelper.instance.kz_pod_enable && self.target.should_build?
14
+ unless self.target.name.start_with?('Pods-')
15
+ KZ::KZGlobalHelper.instance.kz_generator.add_framework_generator_build_phase(target_installation_result.native_target)
16
+ end
17
+
18
+ kz_pod_target = self.target.weakRef_kz_pod_target
19
+ if kz_pod_target&.is_dev_pod
20
+ KZ::KZGlobalHelper.instance.kz_generator.add_flexlib_xml_build_rules(self.project, target_installation_result.native_target)
21
+ end
22
+ end
23
+ target_installation_result
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+
2
+ module Pod
3
+ class Specification
4
+
5
+ def deployment_target(platform_name)
6
+ result = platform_hash[platform_name.to_s]
7
+ result ||= parent.deployment_target(platform_name) if parent
8
+ result = "9.0" if platform_name == "ios" && (result == nil || result.to_f < 9.0)
9
+ result
10
+ end
11
+
12
+ def platform_hash
13
+ case value = attributes_hash['platforms']
14
+ when String
15
+ { value => nil }
16
+ when Array
17
+ result = {}
18
+ value.each do |a_value|
19
+ result[a_value] = nil
20
+ end
21
+ result
22
+ when Hash
23
+ ios = value["ios"]
24
+ value["ios"] = 9.0 if ios == nil || ios.to_f < 9.0
25
+ value
26
+ else
27
+ {}
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,34 @@
1
+
2
+ module Pod
3
+ class Target
4
+ attr_accessor :weakRef_kz_pod_target
5
+
6
+ alias_method :origin_product_basename, :product_basename
7
+ def product_basename
8
+ if self.weakRef_kz_pod_target
9
+ self.weakRef_kz_pod_target.product_basename
10
+ else
11
+ origin_product_basename
12
+ end
13
+ end
14
+
15
+
16
+ def framework_name
17
+ if self.weakRef_kz_pod_target
18
+ self.weakRef_kz_pod_target.product_name
19
+ else
20
+ "#{product_module_name}.framework"
21
+ end
22
+ end
23
+
24
+ alias_method :origin_product_name, :product_name
25
+ def product_name
26
+ if self.weakRef_kz_pod_target
27
+ self.weakRef_kz_pod_target.product_name
28
+ else
29
+ origin_product_name
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,125 @@
1
+ require 'cocoapods-kz/helpers/kz_global_helper'
2
+ require 'cocoapods-kz/helpers/kz_pod_target'
3
+ require 'xcodeproj'
4
+
5
+ module Pod
6
+ class Installer
7
+ class Xcode
8
+ class PodsProjectGenerator
9
+ module TargetInstallerHelper
10
+
11
+ alias_method :origin_update_changed_file, :update_changed_file
12
+ def update_changed_file(generator, path)
13
+ unless KZ::KZGlobalHelper.instance.kz_pod_enable
14
+ origin_update_changed_file(generator, path)
15
+ return
16
+ end
17
+
18
+ if generator.is_a?(Pod::Target::BuildSettings::AggregateTargetSettings)
19
+ unless self.target.application_extension_api_only
20
+ xcconfig = generator.xcconfig
21
+ kz_clean_xcconfig(xcconfig)
22
+ main_hamp_search_path = '"' + KZ::KZ_POD_CONFIG_ROOT_STR + "/#{self.target.user_project.root_object.display_name}.hmap" + '"'
23
+ pod_targets = self.target.pod_targets_for_build_configuration(generator.configuration_name)
24
+ pod_targets.each do |native_pod_target|
25
+ kz_pod_target = native_pod_target.weakRef_kz_pod_target
26
+ if kz_pod_target
27
+ if kz_pod_target.repair_header_search_path
28
+ main_hamp_search_path += (' ' + KZ.deal_path_for_xcconfig(kz_pod_target.repair_header_search_path, true))
29
+ end
30
+ add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths)
31
+ end
32
+ end
33
+ xcconfig.attributes['HEADER_SEARCH_PATHS'] = main_hamp_search_path
34
+ xcconfig.attributes['USE_HEADERMAP'] = 'NO'
35
+
36
+ if generator.configuration_name == 'Debug' && check_default_xcode_version_for_ld64
37
+ other_linker_flags = xcconfig.other_linker_flags[:simple]
38
+ other_linker_flags << '-ld64'
39
+ end
40
+ kz_update_xcconfig_file(xcconfig, path)
41
+ return
42
+ end
43
+ elsif generator.is_a?(Pod::Target::BuildSettings::PodTargetSettings)
44
+ kz_pod_target = self.target.weakRef_kz_pod_target
45
+ if kz_pod_target
46
+ xcconfig = generator.xcconfig
47
+ xcconfig.attributes['HEADER_SEARCH_PATHS'] = kz_pod_target.header_search_paths
48
+ xcconfig.attributes['USE_HEADERMAP'] = 'NO'
49
+ framework_cache_path = KZ.deal_path_for_xcconfig(kz_pod_target.pod_config_cache_path(true))
50
+ xcconfig.attributes['KZ_FRAMEWORK_CACHE_PATH'] = framework_cache_path
51
+ xcconfig.attributes['KZ_MERGE_SWIFT_H_PATH'] = KZ::KZGlobalHelper.instance.kz_merge_swift_h_path
52
+
53
+ add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths)
54
+ kz_update_xcconfig_file(xcconfig, path)
55
+ return
56
+ end
57
+ end
58
+ origin_update_changed_file(generator, path)
59
+ end
60
+
61
+ def add_repair_modulemap(xcconfig, repair_modulemap_paths)
62
+ if repair_modulemap_paths.count > 0
63
+ repair_modulemap_paths.each do |repair_modulemap_path|
64
+ fmodule_map = ' -fmodule-map-file=' + KZ.deal_path_for_xcconfig(repair_modulemap_path, true)
65
+ unless xcconfig.attributes['OTHER_CFLAGS'].include?(fmodule_map)
66
+ xcconfig.attributes['OTHER_CFLAGS'] += fmodule_map
67
+ end
68
+ xfmodule_map = ' -Xcc -fmodule-map-file=' + KZ.deal_path_for_xcconfig(repair_modulemap_path, true)
69
+ unless xcconfig.attributes['OTHER_SWIFT_FLAGS'].include?(xfmodule_map)
70
+ xcconfig.attributes['OTHER_SWIFT_FLAGS'] += xfmodule_map
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ def kz_update_xcconfig_file(xcconfig, path)
77
+ if path.exist?
78
+ contents = xcconfig.to_s
79
+ content_stream = StringIO.new(contents)
80
+ identical = File.open(path, 'rb') { |f| FileUtils.compare_stream(f, content_stream) }
81
+ return if identical
82
+
83
+ File.open(path, 'w') { |f| f.write(contents) }
84
+ else
85
+ path.dirname.mkpath
86
+ xcconfig.save_as(path)
87
+ end
88
+ end
89
+
90
+ def kz_clean_xcconfig(xcconfig)
91
+ other_cflags = xcconfig.attributes['OTHER_CFLAGS']
92
+ flags = other_cflags.split(' ')
93
+ new_flags = []
94
+ appear_delete_tag = false
95
+ flags.each do |flag|
96
+ if flag.include?('isystem') || flag.include?('iframework')
97
+ appear_delete_tag = true
98
+ else
99
+ unless appear_delete_tag || new_flags.include?(flag)
100
+ new_flags << flag
101
+ end
102
+ appear_delete_tag = false
103
+ end
104
+ end
105
+ xcconfig.attributes['OTHER_CFLAGS'] = new_flags.join(' ')
106
+ end
107
+
108
+ def check_default_xcode_version_for_ld64
109
+ default_xcode_path = Pathname.new('/Applications/Xcode.app')
110
+ return false unless File.exist?(default_xcode_path)
111
+
112
+ xcode_info_plist = default_xcode_path + 'Contents/Info.plist'
113
+ _xcode_info_plist = KZ::KZ_POD_CONFIG_ROOT + 'Xcode_Info.plist'
114
+ FileUtils.cp(xcode_info_plist, _xcode_info_plist)
115
+ system "plutil -convert xml1 #{_xcode_info_plist.to_s} #{_xcode_info_plist.to_s}"
116
+ plist_hash = Xcodeproj::Plist.read_from_path(_xcode_info_plist)
117
+ FileUtils.rm(_xcode_info_plist)
118
+ plist_hash['CFBundleShortVersionString'] == '15.0'
119
+ end
120
+
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
@@ -1,11 +1,15 @@
1
1
  require 'cocoapods'
2
2
  require_relative 'gem_version'
3
3
 
4
- if Pod.match_version?('~> 1.4')
4
+ if Pod.match_version?('~> 1.11')
5
5
  require 'cocoapods-kz/native/dls'
6
6
  require 'cocoapods-kz/native/installer'
7
7
  require 'cocoapods-kz/native/acknowledgements'
8
8
  require 'cocoapods-kz/native/analyzer'
9
9
  require 'cocoapods-kz/native/file_accessor'
10
- require 'cocoapods-kz/native/user_project_integrator'
10
+ require 'cocoapods-kz/native/target'
11
+ require 'cocoapods-kz/native/target_installer_helper'
12
+ require 'cocoapods-kz/native/pod_target'
13
+ require 'cocoapods-kz/native/pod_target_installer'
14
+ require 'cocoapods-kz/native/specification'
11
15
  end