cocoapods-kz 0.0.9 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-kz/command/clean.rb +30 -23
  3. data/lib/cocoapods-kz/command/info.rb +37 -0
  4. data/lib/cocoapods-kz/command/install.rb +13 -3
  5. data/lib/cocoapods-kz/command/kz.rb +1 -0
  6. data/lib/cocoapods-kz/command/repair.rb +1 -0
  7. data/lib/cocoapods-kz/command/update.rb +13 -3
  8. data/lib/cocoapods-kz/gem_version.rb +1 -1
  9. data/lib/cocoapods-kz/helpers/kz_analyzer.rb +20 -6
  10. data/lib/cocoapods-kz/helpers/kz_config_result.rb +1 -1
  11. data/lib/cocoapods-kz/helpers/kz_framework_manager.rb +167 -1
  12. data/lib/cocoapods-kz/helpers/kz_generator.rb +19 -5
  13. data/lib/cocoapods-kz/helpers/kz_global_helper.rb +21 -4
  14. data/lib/cocoapods-kz/helpers/kz_log.rb +11 -0
  15. data/lib/cocoapods-kz/helpers/kz_pod_target.rb +81 -15
  16. data/lib/cocoapods-kz/native/dls.rb +10 -0
  17. data/lib/cocoapods-kz/native/file_accessor.rb +8 -3
  18. data/lib/cocoapods-kz/native/installer.rb +28 -5
  19. data/lib/cocoapods-kz/native/pod_target.rb +10 -0
  20. data/lib/cocoapods-kz/native/pod_target_installer.rb +22 -6
  21. data/lib/cocoapods-kz/native/pod_target_integrator.rb +62 -0
  22. data/lib/cocoapods-kz/native/pods_project_writer.rb +22 -0
  23. data/lib/cocoapods-kz/native/target_installer_helper.rb +39 -2
  24. data/lib/cocoapods-kz/native.rb +2 -1
  25. data/lib/cocoapods-kz/resources/arm64ToSimulator +0 -0
  26. data/lib/cocoapods-kz/resources/kz_fix_force_load_exe.sh +12 -0
  27. data/lib/cocoapods-kz/resources/kz_generator_framework.sh +18 -22
  28. data/lib/cocoapods-kz/resources/kz_refresh_pods_pbxproj.rb +17 -0
  29. metadata +9 -4
  30. data/lib/cocoapods-kz/native/analyzer.rb +0 -23
  31. data/lib/cocoapods-kz/resources/kz_merge_swift_h.rb +0 -14
@@ -27,17 +27,27 @@ module KZ
27
27
  attr_accessor :private_header_search_path
28
28
  attr_accessor :repair_header_search_path
29
29
 
30
+ attr_accessor :platform_name
30
31
  # target编译最终的产物名称
31
32
  attr_accessor :product_name
32
33
  # 对应xcode配置PRODUCT_NAME,当多个target的PRODUCT_NAME相同时,需要手动修改,防止打包报错
33
34
  attr_accessor :product_basename
34
- # 当手动修改PRODUCT_NAME之后,@import需要修复为原使用方式
35
+ # 当手动修改PRODUCT_NAME之后,产物名称会改变,在framework模式下对于OC组件需要使用modulemap文件配置寻找路径,对于Swift组件需要配置单独的include path
35
36
  attr_accessor :repair_modulemap_path
37
+ attr_accessor :repair_swift_include_path
38
+
36
39
  # 当手动修改PRODUCT_NAME之后,#import<xx/xxx.h>需要修复为原使用方式,使用hmap进行映射
37
40
  attr_accessor :need_repair_module_import
38
41
 
39
42
  attr_accessor :use_local_private_headers_path
40
43
 
44
+ attr_accessor :force_load
45
+ attr_accessor :force_load_info
46
+
47
+ attr_accessor :use_modulemap
48
+
49
+ attr_accessor :disable_to_simulator_frameworks
50
+
41
51
  def initialize(native_pod_target)
42
52
  @native_pod_target = native_pod_target
43
53
  @name = native_pod_target.name
@@ -49,10 +59,14 @@ module KZ
49
59
  @is_dev_pod = false
50
60
  @config_pod_mode = :kz_pod_origin_mode
51
61
 
62
+ @platform_name = native_pod_target.platform.symbolic_name
52
63
  @product_name = native_pod_target.origin_product_name
53
64
  @product_basename = native_pod_target.origin_product_basename
54
65
  @need_repair_module_import = false
55
66
  @use_local_private_headers_path = false
67
+ @force_load = false
68
+ @use_modulemap = true
69
+ @disable_to_simulator_frameworks = []
56
70
 
57
71
  native_pod_target.file_accessors.each do |file_accessor|
58
72
  file_accessor.kz_pod_target = self
@@ -66,7 +80,6 @@ module KZ
66
80
  end
67
81
 
68
82
  def all_headers
69
- return [] unless have_download_pod?
70
83
  @all_headers ||= begin
71
84
  all_headers = []
72
85
  native_pod_target.file_accessors.each do |file_accessor|
@@ -79,8 +92,6 @@ module KZ
79
92
  end
80
93
 
81
94
  def public_headers
82
- return [] unless have_download_pod?
83
-
84
95
  @public_headers ||= begin
85
96
  public_headers = []
86
97
  native_pod_target.file_accessors.each do |file_accessor|
@@ -142,6 +153,17 @@ module KZ
142
153
  @repair_import << kz_repair_pod_target if kz_repair_pod_target
143
154
  end
144
155
  end
156
+
157
+ force_load = pod_config[:force_load]
158
+ if force_load.is_a?(TrueClass)
159
+ @force_load = true
160
+ end
161
+
162
+ use_modulemap = pod_config[:use_modulemap]
163
+ if use_modulemap.is_a?(FalseClass)
164
+ @use_modulemap = false
165
+ end
166
+
145
167
  end
146
168
 
147
169
  # 在当前target的所有依赖中,过滤有有修补的target
@@ -169,6 +191,8 @@ module KZ
169
191
 
170
192
  # 直接用于配置HEADER_SEARCH_PATHS
171
193
  def header_search_paths(custom_paths)
194
+ return '' unless current_should_build?
195
+
172
196
  header_search_paths = ''
173
197
  header_search_paths = KZ.deal_path_for_xcconfig(@private_header_search_path, true) if @private_header_search_path
174
198
  repair_header_search_paths = self.all_repair_header_search_paths.join(' ')
@@ -207,11 +231,11 @@ module KZ
207
231
  end
208
232
 
209
233
  # 获取target对应的配置根目录,部分文件需要依赖版本进行存储
210
- def pod_config_cache_path(concat_version)
211
- kz_target_framework_folder = KZ_POD_CONFIG_POD_TARGETS + @name
212
- kz_target_framework_folder += @version if concat_version
213
- FileUtils.mkdir_p(kz_target_framework_folder) unless File.exist?(kz_target_framework_folder) || concat_version
214
- kz_target_framework_folder
234
+ def pod_config_cache_path(concat_version, vendored_framework = false)
235
+ kz_target_config_folder = KZ_POD_CONFIG_POD_TARGETS + @name
236
+ kz_target_config_folder += "vendored_framework" if vendored_framework
237
+ kz_target_config_folder += @version if concat_version
238
+ kz_target_config_folder
215
239
  end
216
240
 
217
241
  # 获取target中的module name,默认为product_module_name与target.name也相同。
@@ -242,23 +266,58 @@ module KZ
242
266
  all_repair_modulemap_paths
243
267
  end
244
268
 
269
+ def all_repair_swift_include_paths
270
+ all_repair_swift_include_paths = []
271
+ all_repair_swift_include_paths << repair_swift_include_path if self.repair_swift_include_path
272
+ recursive_dependent_targets.each do |recursive_dependent_target|
273
+ all_repair_swift_include_paths.concat(recursive_dependent_target.all_repair_swift_include_paths)
274
+ end
275
+ all_repair_swift_include_paths.uniq! if all_repair_swift_include_paths.count > 0
276
+ all_repair_swift_include_paths
277
+ end
278
+
245
279
  def prefix_header_path
246
280
  @native_pod_target.prefix_header_path
247
281
  end
248
282
 
249
- def have_download_pod?
250
- native_pod_dir = @native_pod_target.sandbox.pod_dir(@root_name)
251
- File.exist?(native_pod_dir) && !File.empty?(native_pod_dir)
283
+ # 当前pod是否存在可编译的文件,配置framework后当前pod就不存在可编译文件
284
+ def current_should_build?
285
+ @native_pod_target.should_build?
252
286
  end
253
287
 
254
- def should_build?
255
- have_download_pod? ? @native_pod_target.should_build? : false
288
+ # 原pod是否存在可编译的文件
289
+ def origin_should_build?
290
+ return @origin_should_build if defined? @origin_should_build
291
+ accessors = @native_pod_target.file_accessors.select { |fa| fa.spec.library_specification? }
292
+ all_origin_compile_files = []
293
+ accessors.each do |accessor|
294
+ all_origin_compile_files.concat(accessor.origin_source_files - accessor.kz_headers)
295
+ end
296
+ @origin_should_build = !all_origin_compile_files.empty?
256
297
  end
257
298
 
258
- def uses_swift?
299
+ def current_uses_swift?
259
300
  @native_pod_target.uses_swift?
260
301
  end
261
302
 
303
+ def origin_uses_swift?
304
+ return @uses_swift if defined? @uses_swift
305
+ @uses_swift = (!origin_should_build? && !@native_pod_target.spec_swift_versions.empty?) ||
306
+ @native_pod_target.file_accessors.select { |a| a.spec.library_specification? }.any? do |file_accessor|
307
+ uses_swift_for_spec?(file_accessor.spec)
308
+ end
309
+ end
310
+
311
+ def uses_swift_for_spec?(spec)
312
+ @uses_swift_for_spec_cache ||= {}
313
+ return @uses_swift_for_spec_cache[spec.name] if @uses_swift_for_spec_cache.key?(spec.name)
314
+ @uses_swift_for_spec_cache[spec.name] = begin
315
+ file_accessor = @native_pod_target.file_accessors.find { |fa| fa.spec == spec }
316
+ raise "[Bug] Unable to find file accessor for spec `#{spec.inspect}` in pod target `#{label}`" unless file_accessor
317
+ file_accessor.origin_source_files.any? { |sf| sf.extname == '.swift' }
318
+ end
319
+ end
320
+
262
321
  def local_private_headers_path
263
322
  @local_private_headers_path ||= begin
264
323
  path = KZ_POD_CONFIG_POD_TARGETS + @name + "Headers"
@@ -267,5 +326,12 @@ module KZ
267
326
  end
268
327
  end
269
328
 
329
+ def configuration_build_dir(for_froce_load = false)
330
+ if for_froce_load
331
+ return @native_pod_target.configuration_build_dir + "/.force_load"
332
+ end
333
+ @native_pod_target.configuration_build_dir
334
+ end
335
+
270
336
  end
271
337
  end
@@ -27,6 +27,16 @@ module Pod
27
27
  kz_pod_config[name][:repair_import] = repair_import
28
28
  end
29
29
 
30
+ force_load = pod_attach.delete(:force_load)
31
+ if force_load
32
+ kz_pod_config[name][:force_load] = force_load
33
+ end
34
+
35
+ use_modulemap = pod_attach.delete(:use_modulemap)
36
+ if use_modulemap != nil
37
+ kz_pod_config[name][:use_modulemap] = use_modulemap
38
+ end
39
+
30
40
  KZ::KZGlobalHelper.instance.kz_pod_config.merge!(kz_pod_config)
31
41
  end
32
42
 
@@ -72,10 +72,15 @@ module Pod
72
72
 
73
73
  alias_method :origin_vendored_frameworks, :vendored_frameworks
74
74
  def vendored_frameworks
75
- result = KZ::KZGlobalHelper.instance.pod_config_result_with_target(self.kz_pod_target)
76
- if !self.spec.test_specification && result
75
+ if self.kz_pod_target
77
76
  frameworks = origin_vendored_frameworks
78
- frameworks.concat(result.get_framework_paths)
77
+ if KZ::KZGlobalHelper.instance.arm64_simulator && frameworks.count > 0
78
+ frameworks = KZ::KZFrameworkManager.handle_origin_framework(frameworks, self.kz_pod_target)
79
+ end
80
+ result = KZ::KZGlobalHelper.instance.pod_config_result_with_target(self.kz_pod_target)
81
+ if !self.spec.test_specification && result
82
+ frameworks.concat(result.get_framework_paths)
83
+ end
79
84
  frameworks
80
85
  else
81
86
  origin_vendored_frameworks
@@ -1,12 +1,21 @@
1
1
  require 'cocoapods/installer'
2
+ require 'cocoapods-kz/helpers/kz_global_helper'
3
+ require 'cocoapods-kz/helpers/kz_generator'
2
4
 
3
5
  module Pod
4
6
  class Installer
5
- alias_method :original_integrate_user_project, :integrate_user_project
6
- def integrate_user_project
7
- original_integrate_user_project
8
- if KZ::KZGlobalHelper.instance.kz_pod_enable
9
- KZ::KZGlobalHelper.instance.write_lock_file
7
+
8
+ alias_method :original_download_dependencies, :download_dependencies
9
+ def download_dependencies
10
+ original_download_dependencies
11
+
12
+ # 因为kz_pod_target提供不少方法,需要判断pod文件情况,所以依赖分析需要挪到download之后
13
+ if KZ::KZGlobalHelper.instance.generate_kz_pod_targets
14
+ main_project = aggregate_targets.first.user_project
15
+ kz_analyer = KZ::KZAnalyzer.new(pod_targets, self.sandbox.development_pods)
16
+ kz_analyer.analyer
17
+ KZ::KZGlobalHelper.instance.kz_analyzer = kz_analyer
18
+ KZ::KZGlobalHelper.instance.kz_generator = KZ::KZGenerator.new(main_project)
10
19
  end
11
20
  end
12
21
 
@@ -18,5 +27,19 @@ module Pod
18
27
  end
19
28
  original_integrate
20
29
  end
30
+
31
+ # pod结束
32
+ alias_method :original_install!, :install!
33
+ def install!
34
+ original_install!
35
+
36
+ if KZ::KZGlobalHelper.instance.kz_pod_enable
37
+ KZ::KZGlobalHelper.instance.write_lock_file
38
+
39
+ current_pods_pbxproj_path = self.pods_project.path + 'project.pbxproj'
40
+ temp_pods_pbxproj_path = KZ::KZ_POD_CONFIG_POD_TEMPDIR + 'project.pbxproj'
41
+ system("(sleep 1 && ruby '#{KZ::KZ_FEFRESH_PODS_PBXPROJ}' '#{current_pods_pbxproj_path}' '#{temp_pods_pbxproj_path}') &")
42
+ end
43
+ end
21
44
  end
22
45
  end
@@ -13,5 +13,15 @@ module Pod
13
13
  end
14
14
  end
15
15
 
16
+ alias_method :origin_defines_module?, :defines_module?
17
+ def defines_module?
18
+ origin_result = origin_defines_module?
19
+ kz_pod_target = self.weakRef_kz_pod_target
20
+ if kz_pod_target && !kz_pod_target.use_modulemap
21
+ return false
22
+ end
23
+ return origin_result
24
+ end
25
+
16
26
  end
17
27
  end
@@ -10,16 +10,32 @@ module Pod
10
10
  alias_method :origin_install!, :install!
11
11
  def install!
12
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)
13
+ if KZ::KZGlobalHelper.instance.kz_pod_enable
14
+ kz_pod_target = self.target.weakRef_kz_pod_target
15
+
16
+ if self.target.should_build?
17
+ unless self.target.name.start_with?('Pods-')
18
+ KZ::KZGlobalHelper.instance.kz_generator.add_framework_generator_build_phase(target_installation_result.native_target)
19
+ end
20
+
21
+ if kz_pod_target&.is_dev_pod
22
+ KZ::KZGlobalHelper.instance.kz_generator.add_flexlib_xml_build_rules(self.project, target_installation_result.native_target)
23
+ end
16
24
  end
17
25
 
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)
26
+ if kz_pod_target&.origin_should_build?
27
+ if kz_pod_target.force_load
28
+ KZ::KZGlobalHelper.instance.kz_generator.add_force_load_exe_path_build_phase(target_installation_result.native_target, kz_pod_target.force_load_info)
29
+ end
30
+ end
31
+
32
+ if kz_pod_target && !kz_pod_target.use_modulemap
33
+ target_installation_result.native_target.build_configurations.each do |c|
34
+ c.build_settings['DEFINES_MODULE'] = 'NO'
35
+ end
21
36
  end
22
37
  end
38
+
23
39
  target_installation_result
24
40
  end
25
41
 
@@ -0,0 +1,62 @@
1
+ module Pod
2
+ class Installer
3
+ class Xcode
4
+ class PodsProjectGenerator
5
+
6
+ class PodTargetIntegrator
7
+ $global_output_paths_avoid_duplicate = []
8
+
9
+ def add_copy_xcframeworks_script_phase(native_target)
10
+ script_path = "${PODS_ROOT}/#{target.copy_xcframeworks_script_path.relative_path_from(target.sandbox.root)}"
11
+
12
+ input_paths_by_config = {}
13
+ output_paths_by_config = {}
14
+
15
+ xcframeworks = target.xcframeworks.values.flatten
16
+
17
+ if use_input_output_paths? && !xcframeworks.empty?
18
+ input_file_list_path = target.copy_xcframeworks_script_input_files_path
19
+ input_file_list_relative_path = "${PODS_ROOT}/#{input_file_list_path.relative_path_from(target.sandbox.root)}"
20
+ input_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(input_file_list_path, input_file_list_relative_path)
21
+ input_paths = input_paths_by_config[input_paths_key] = [script_path]
22
+
23
+ framework_paths = xcframeworks.map { |xcf| "${PODS_ROOT}/#{xcf.path.relative_path_from(target.sandbox.root)}" }
24
+ input_paths.concat framework_paths
25
+
26
+ output_file_list_path = target.copy_xcframeworks_script_output_files_path
27
+ output_file_list_relative_path = "${PODS_ROOT}/#{output_file_list_path.relative_path_from(target.sandbox.root)}"
28
+ output_paths_key = UserProjectIntegrator::TargetIntegrator::XCFileListConfigKey.new(output_file_list_path, output_file_list_relative_path)
29
+ output_paths_by_config[output_paths_key] = xcframeworks.map do |xcf|
30
+ "#{Target::BuildSettings::XCFRAMEWORKS_BUILD_DIR_VARIABLE}/#{xcf.target_name}/#{xcf.name}.framework"
31
+ end
32
+ end
33
+
34
+ if xcframeworks.empty?
35
+ UserProjectIntegrator::TargetIntegrator.remove_copy_xcframeworks_script_phase_from_target(native_target)
36
+ else
37
+ if target_installation_result.target.scope_suffix
38
+ output_paths_by_config.each do |key, value|
39
+ if value && value.count > 0
40
+ need_remove_paths = []
41
+ value.each do |path|
42
+ if $global_output_paths_avoid_duplicate.include?(path)
43
+ need_remove_paths.append(path)
44
+ else
45
+ $global_output_paths_avoid_duplicate.append(path)
46
+ end
47
+ end
48
+ need_remove_paths.each do |need_remove_path|
49
+ value.delete(need_remove_path)
50
+ end if need_remove_paths.count > 0
51
+ end
52
+ end
53
+ end
54
+ UserProjectIntegrator::TargetIntegrator.create_or_update_copy_xcframeworks_script_phase_to_target(
55
+ native_target, script_path, input_paths_by_config, output_paths_by_config)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,22 @@
1
+
2
+ module Pod
3
+ class Installer
4
+ class Xcode
5
+ class PodsProjectWriter
6
+ alias_method :origin_def_save_projects, :save_projects
7
+ def save_projects(projects)
8
+ origin_def_save_projects(projects)
9
+
10
+ if KZ::KZGlobalHelper.instance.kz_pod_enable
11
+ projects.each do |project|
12
+ if project.project_name == "Pods"
13
+ project_pbxproj_path = project.path + 'project.pbxproj'
14
+ FileUtils.cp_r(project_pbxproj_path, KZ::KZ_POD_CONFIG_POD_TEMPDIR)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -28,10 +28,19 @@ module Pod
28
28
  main_hamp_search_path += (' ' + KZ.deal_path_for_xcconfig(kz_pod_target.repair_header_search_path, true))
29
29
  end
30
30
  add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths, self.target.uses_swift?)
31
+ add_repair_swift_include_path(xcconfig, kz_pod_target.all_repair_swift_include_paths, self.target.uses_swift?)
32
+
33
+ if kz_pod_target.force_load
34
+ kz_add_force_load_tag(xcconfig, kz_pod_target)
35
+ end
31
36
  end
32
37
  end
33
38
  xcconfig.attributes['HEADER_SEARCH_PATHS'] = main_hamp_search_path
34
39
  xcconfig.attributes['USE_HEADERMAP'] = 'NO'
40
+ if KZ::KZGlobalHelper.instance.arm64_simulator
41
+ xcconfig.attributes.delete("EXCLUDED_ARCHS[sdk=iphonesimulator*]")
42
+ xcconfig.attributes['VALID_ARCHS'] = 'arm64 arm64_32 x86_64'
43
+ end
35
44
 
36
45
  kz_update_xcconfig_file(xcconfig, path)
37
46
  return
@@ -47,9 +56,16 @@ module Pod
47
56
  xcconfig.attributes['USE_HEADERMAP'] = 'NO'
48
57
  framework_cache_path = KZ.deal_path_for_xcconfig(kz_pod_target.pod_config_cache_path(true))
49
58
  xcconfig.attributes['KZ_FRAMEWORK_CACHE_PATH'] = framework_cache_path
50
- xcconfig.attributes['KZ_MERGE_SWIFT_H_PATH'] = KZ.deal_path_for_xcconfig(KZ::KZ_MERGE_SWIFT_H_PATH)
59
+ if kz_pod_target.force_load
60
+ xcconfig.attributes['KZ_FIX_FORCE_LOAD_EXE_FOLDER'] = kz_pod_target.configuration_build_dir(true)
61
+ end
62
+ if KZ::KZGlobalHelper.instance.arm64_simulator
63
+ xcconfig.attributes.delete("EXCLUDED_ARCHS[sdk=iphonesimulator*]")
64
+ xcconfig.attributes['VALID_ARCHS'] = 'arm64 arm64_32 x86_64'
65
+ end
51
66
 
52
- add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths, kz_pod_target.uses_swift?)
67
+ add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths, kz_pod_target.current_uses_swift?)
68
+ add_repair_swift_include_path(xcconfig, kz_pod_target.all_repair_swift_include_paths, kz_pod_target.current_uses_swift?)
53
69
  kz_update_xcconfig_file(xcconfig, path)
54
70
  return
55
71
  end
@@ -74,6 +90,18 @@ module Pod
74
90
  end
75
91
  end
76
92
 
93
+ def add_repair_swift_include_path(xcconfig, repair_swift_include_paths, uses_swift)
94
+ # 只有当前pod支持swift,才需要所依赖的pod提供的swiftmodule
95
+ if repair_swift_include_paths.count > 0 && uses_swift
96
+ repair_swift_include_paths.each do |repair_swift_include_path|
97
+ swift_include_path = ' ' + KZ.deal_path_for_xcconfig(repair_swift_include_path, true)
98
+ unless xcconfig.attributes['SWIFT_INCLUDE_PATHS'].include?(swift_include_path)
99
+ xcconfig.attributes['SWIFT_INCLUDE_PATHS'] += swift_include_path
100
+ end
101
+ end
102
+ end
103
+ end
104
+
77
105
  def kz_update_xcconfig_file(xcconfig, path)
78
106
  if path.exist?
79
107
  contents = xcconfig.to_s
@@ -106,6 +134,15 @@ module Pod
106
134
  xcconfig.attributes['OTHER_CFLAGS'] = new_flags.join(' ')
107
135
  end
108
136
 
137
+ def kz_add_force_load_tag(xcconfig, kz_pod_target)
138
+ other_linker_flags = xcconfig.other_linker_flags
139
+ frameworks_flags = other_linker_flags[:frameworks]
140
+ force_flags = other_linker_flags[:force_load]
141
+
142
+ frameworks_flags.delete(kz_pod_target.product_basename)
143
+ force_flags.add(KZ.deal_path_for_xcconfig(kz_pod_target.force_load_info, true))
144
+ end
145
+
109
146
  end
110
147
  end
111
148
  end
@@ -5,11 +5,12 @@ 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
- require 'cocoapods-kz/native/analyzer'
9
8
  require 'cocoapods-kz/native/file_accessor'
10
9
  require 'cocoapods-kz/native/target'
11
10
  require 'cocoapods-kz/native/target_installer_helper'
12
11
  require 'cocoapods-kz/native/pod_target'
13
12
  require 'cocoapods-kz/native/pod_target_installer'
14
13
  require 'cocoapods-kz/native/specification'
14
+ require 'cocoapods-kz/native/pods_project_writer'
15
+ require 'cocoapods-kz/native/pod_target_integrator'
15
16
  end
@@ -0,0 +1,12 @@
1
+ if [ "${MACH_O_TYPE}" != "staticlib" ]; then
2
+ exit 0
3
+ fi
4
+
5
+ CURRENT_PRODUCT_DIR=${PODS_CONFIGURATION_BUILD_DIR}/${TARGET_NAME}
6
+
7
+ if [ -d "${KZ_FIX_FORCE_LOAD_EXE_FOLDER}" ]; then
8
+ rm -r "${KZ_FIX_FORCE_LOAD_EXE_FOLDER}"
9
+ fi
10
+ mkdir -p "${KZ_FIX_FORCE_LOAD_EXE_FOLDER}"
11
+
12
+ ln -s ${CURRENT_PRODUCT_DIR}/${FULL_PRODUCT_NAME} ${KZ_FIX_FORCE_LOAD_EXE_FOLDER}/${FULL_PRODUCT_NAME}
@@ -2,40 +2,36 @@ if [ "${MACH_O_TYPE}" != "staticlib" ]; then
2
2
  exit 0
3
3
  fi
4
4
 
5
- PRODUCT_DIR=${PODS_BUILD_DIR}/Debug-iphoneos/${TARGET_NAME}/${FULL_PRODUCT_NAME}
6
- PRODUCT_SIMULATOR_DIR=${PODS_BUILD_DIR}/Debug-iphonesimulator/${TARGET_NAME}/${FULL_PRODUCT_NAME}
7
- CURRENT_PRODUCT_DIR=${PODS_CONFIGURATION_BUILD_DIR}/${TARGET_NAME}
8
-
9
5
  if [ -d "${KZ_FRAMEWORK_CACHE_PATH}" ]; then
10
6
  rm -r "${KZ_FRAMEWORK_CACHE_PATH}"
11
7
  fi
12
8
  mkdir -p "${KZ_FRAMEWORK_CACHE_PATH}"
13
9
 
14
- if [ -d "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}" ]; then
15
- rm -r "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}"
16
- fi
17
- cp -r ${CURRENT_PRODUCT_DIR}/${FULL_PRODUCT_NAME} "${KZ_FRAMEWORK_CACHE_PATH}"
18
-
10
+ CURRENT_PRODUCT_DIR=${PODS_CONFIGURATION_BUILD_DIR}/${TARGET_NAME}
19
11
  find "${CURRENT_PRODUCT_DIR}" -iname "*.bundle" | while read -r BUNDLE_FILE; do
20
- BUNDLE_NAME=$(basename ${BUNDLE_FILE})
12
+ BUNDLE_NAME=$(basename "${BUNDLE_FILE}")
21
13
  if [ -d "${KZ_FRAMEWORK_CACHE_PATH}/${BUNDLE_NAME}" ]; then
22
14
  rm -r "${KZ_FRAMEWORK_CACHE_PATH}/${BUNDLE_NAME}"
23
15
  fi
24
- cp -r ${BUNDLE_FILE} "${KZ_FRAMEWORK_CACHE_PATH}"
16
+ cp -r "${BUNDLE_FILE}" "${KZ_FRAMEWORK_CACHE_PATH}"
25
17
  done
26
18
 
27
- if [ -f ${PRODUCT_DIR}/${PRODUCT_NAME} ] && [ -f ${PRODUCT_SIMULATOR_DIR}/${PRODUCT_NAME} ]; then
28
- lipo -create ${PRODUCT_DIR}/${PRODUCT_NAME} ${PRODUCT_SIMULATOR_DIR}/${PRODUCT_NAME} -output "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}/${PRODUCT_NAME}"
19
+ OPPOSE_PLATFORM_NAME=''
20
+ if [ -n "${CORRESPONDING_SIMULATOR_PLATFORM_NAME+set}" ]; then
21
+ OPPOSE_PLATFORM_NAME=${CORRESPONDING_SIMULATOR_PLATFORM_NAME}
22
+ elif [ -n "${CORRESPONDING_DEVICE_PLATFORM_NAME+set}" ]; then
23
+ OPPOSE_PLATFORM_NAME=${CORRESPONDING_DEVICE_PLATFORM_NAME}
29
24
  fi
30
25
 
31
- if [ -d ${PRODUCT_DIR}/Modules/${PRODUCT_NAME}.swiftmodule ] && [ -d ${PRODUCT_SIMULATOR_DIR}/Modules/${PRODUCT_NAME}.swiftmodule ]; then
32
- cp -r ${PRODUCT_DIR}/Modules/${PRODUCT_NAME}.swiftmodule "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}/Modules"
33
- cp -r ${PRODUCT_SIMULATOR_DIR}/Modules/${PRODUCT_NAME}.swiftmodule "${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}/Modules"
26
+ if [ "${OPPOSE_PLATFORM_NAME}" = "" ]; then
27
+ exit 0
34
28
  fi
35
29
 
36
- PRODUCT_SWIFT_H=${PRODUCT_DIR}/Headers/${PRODUCT_NAME}-Swift.h
37
- PRODUCT_SIMULATOR_SWIFT_H=${PRODUCT_SIMULATOR_DIR}/Headers/${PRODUCT_NAME}-Swift.h
38
- TARGET_SWIFT_H=${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}/Headers/${PRODUCT_NAME}-Swift.h
39
- if [ -f $PRODUCT_SWIFT_H ] && [ -f $PRODUCT_SIMULATOR_SWIFT_H ]; then
40
- ruby "$KZ_MERGE_SWIFT_H_PATH" "$PRODUCT_SWIFT_H" "$PRODUCT_SIMULATOR_SWIFT_H" "$TARGET_SWIFT_H"
41
- fi
30
+ OPPOSE_PRODUCT_FULL_DIR=${PODS_BUILD_DIR}/${CONFIGURATION}-${OPPOSE_PLATFORM_NAME}/${TARGET_NAME}/${FULL_PRODUCT_NAME}
31
+ if [ -d "${OPPOSE_PRODUCT_FULL_DIR}" ]; then
32
+ xcodebuild -create-xcframework -allow-internal-distribution -framework $(readlink -f "${CURRENT_PRODUCT_DIR}/${FULL_PRODUCT_NAME}") -framework $(readlink -f "${OPPOSE_PRODUCT_FULL_DIR}") \
33
+ -output "${KZ_FRAMEWORK_CACHE_PATH}/${PRODUCT_NAME}.xcframework"
34
+ else
35
+ xcodebuild -create-xcframework -allow-internal-distribution -framework $(readlink -f "${CURRENT_PRODUCT_DIR}/${FULL_PRODUCT_NAME}") \
36
+ -output "${KZ_FRAMEWORK_CACHE_PATH}/${PRODUCT_NAME}.xcframework"
37
+ fi
@@ -0,0 +1,17 @@
1
+ require 'fileutils'
2
+ require 'pathname'
3
+
4
+ current_pods_pbxproj_path = Pathname.new(ARGV[0])
5
+ temp_pods_pbxproj_path = Pathname.new(ARGV[1])
6
+
7
+ if !File.exist?(current_pods_pbxproj_path) || !FileUtils.compare_file(current_pods_pbxproj_path, temp_pods_pbxproj_path)
8
+ FileUtils.cp_r(temp_pods_pbxproj_path, current_pods_pbxproj_path)
9
+ end
10
+
11
+ FileUtils.rm_r(Pathname(temp_pods_pbxproj_path).dirname)
12
+
13
+ xcode_running = system("ps aux | grep '[X]code' > /dev/null 2>&1")
14
+ if xcode_running
15
+ system("touch #{current_pods_pbxproj_path}")
16
+ end
17
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-kz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - yixiong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-12 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -48,6 +48,7 @@ files:
48
48
  - lib/cocoapods-kz.rb
49
49
  - lib/cocoapods-kz/command.rb
50
50
  - lib/cocoapods-kz/command/clean.rb
51
+ - lib/cocoapods-kz/command/info.rb
51
52
  - lib/cocoapods-kz/command/install.rb
52
53
  - lib/cocoapods-kz/command/kz.rb
53
54
  - lib/cocoapods-kz/command/repair.rb
@@ -58,24 +59,28 @@ files:
58
59
  - lib/cocoapods-kz/helpers/kz_framework_manager.rb
59
60
  - lib/cocoapods-kz/helpers/kz_generator.rb
60
61
  - lib/cocoapods-kz/helpers/kz_global_helper.rb
62
+ - lib/cocoapods-kz/helpers/kz_log.rb
61
63
  - lib/cocoapods-kz/helpers/kz_pod_target.rb
62
64
  - lib/cocoapods-kz/helpers/repair_dynamic_swift.rb
63
65
  - lib/cocoapods-kz/helpers/repair_module_import.rb
64
66
  - lib/cocoapods-kz/native.rb
65
67
  - lib/cocoapods-kz/native/acknowledgements.rb
66
- - lib/cocoapods-kz/native/analyzer.rb
67
68
  - lib/cocoapods-kz/native/dls.rb
68
69
  - lib/cocoapods-kz/native/file_accessor.rb
69
70
  - lib/cocoapods-kz/native/installer.rb
70
71
  - lib/cocoapods-kz/native/pod_target.rb
71
72
  - lib/cocoapods-kz/native/pod_target_installer.rb
73
+ - lib/cocoapods-kz/native/pod_target_integrator.rb
74
+ - lib/cocoapods-kz/native/pods_project_writer.rb
72
75
  - lib/cocoapods-kz/native/specification.rb
73
76
  - lib/cocoapods-kz/native/target.rb
74
77
  - lib/cocoapods-kz/native/target_installer_helper.rb
75
78
  - lib/cocoapods-kz/resources/FlexCompiler
79
+ - lib/cocoapods-kz/resources/arm64ToSimulator
76
80
  - lib/cocoapods-kz/resources/hmap
81
+ - lib/cocoapods-kz/resources/kz_fix_force_load_exe.sh
77
82
  - lib/cocoapods-kz/resources/kz_generator_framework.sh
78
- - lib/cocoapods-kz/resources/kz_merge_swift_h.rb
83
+ - lib/cocoapods-kz/resources/kz_refresh_pods_pbxproj.rb
79
84
  - lib/cocoapods-kz/resources/kz_xml_build.sh
80
85
  - lib/cocoapods_plugin.rb
81
86
  homepage: https://github.com/EXAMPLE/cocoapods-kz