cocoapods-kz 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cd6c7deb2a958e5306602d1e1010400b44643a642a27333be9fa8d93405c38f
4
- data.tar.gz: 813cf28a218e20fb79a15e284c69dafee039949c2c9c21e4f7467f8350215ade
3
+ metadata.gz: 9f2ecfbcbc07e3ac505466898ae1b82fe6daf936bcfc56d7a128c7256a000888
4
+ data.tar.gz: '07248a9d57a52e6f2948b2d893d7463d8581f90d4bf29104df5d3465f991355c'
5
5
  SHA512:
6
- metadata.gz: 61cd3bff4c6e8d50118395abaf1ebcff6e89f6ca9f64d98b636617e62c0c5bb5d8b3d7b5646e4496230d11da36d4a7bf4d9e5f8dec585107b06f3b7ba22d76b4
7
- data.tar.gz: 7e47fda547a29835c34f4c761ff9d521aa26bd12f4e19bb37902f7e19751fe970e3b0dd0816204c12bf94d5d5fbca699da35576598ef5ce28bed2fe69e24acaf
6
+ metadata.gz: b32004addf7c59b259281c83d92fab22dc85d5e7f021992f9a3a86af996d8c3de764885fc6bf8b44b2094716743d9cb45133398f4468733c95def92fba911886
7
+ data.tar.gz: 4552647daba1c5c5265bc67302e84788a17bed18d6d87c93e70f90c6d3e97d393c342f6109f1f2f43e3a82ad3ab7071168e39df64b4b9ab35f9b3a308d6a06a8
@@ -0,0 +1,37 @@
1
+ require 'json'
2
+
3
+ module Pod
4
+ class Command
5
+ class Kz < Command
6
+ class Info < Kz
7
+ self.summary = 'pod kz info,用于打印项目pod信息'
8
+
9
+ self.description = <<-DESC
10
+ 结合可选子命令用于执行各种修补脚本
11
+ DESC
12
+
13
+ def initialize(argv)
14
+ KZ::KZGlobalHelper.instance.analyze_special_parameters(true, false, argv.arguments!)
15
+ KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
16
+ super
17
+ end
18
+
19
+ def run
20
+ installer = installer_for_config
21
+ installer.prepare
22
+ installer.resolve_dependencies
23
+ installer.download_dependencies
24
+
25
+ result_info = {}
26
+ KZ::KZGlobalHelper.instance.kz_analyzer.all_kz_pod_targets.values.each do |kz_pod_target|
27
+ pod_info = {}
28
+ pod_info["path"] = kz_pod_target.native_pod_target.sandbox.pod_dir(kz_pod_target.name)
29
+ pod_info["is_dev"] = kz_pod_target.is_dev_pod
30
+ result_info[kz_pod_target.name] = pod_info
31
+ end
32
+ puts result_info.to_json
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -29,7 +29,7 @@ module Pod
29
29
  def initialize(argv)
30
30
  use_code_tag = argv.flag?('code')
31
31
  use_framework_tag = argv.flag?('framework')
32
- banner! if use_code_tag && use_framework_tag
32
+ banner! if (use_code_tag && use_framework_tag) || (!use_code_tag && !use_framework_tag && !argv.empty?)
33
33
 
34
34
  KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
35
35
  if Pod.match_version?('~> 1.11')
@@ -2,6 +2,7 @@ require_relative 'install'
2
2
  require_relative 'update'
3
3
  require_relative 'repair'
4
4
  require_relative 'clean'
5
+ require_relative 'info'
5
6
 
6
7
  module Pod
7
8
  class Command
@@ -35,6 +35,7 @@ module Pod
35
35
  installer = installer_for_config
36
36
  installer.prepare
37
37
  installer.resolve_dependencies
38
+ installer.download_dependencies
38
39
 
39
40
  if @repair_dynamic_swift
40
41
  KZ::KZSwiftAttachOCFeature.new.repair
@@ -29,7 +29,7 @@ module Pod
29
29
  def initialize(argv)
30
30
  use_code_tag = argv.flag?('code')
31
31
  use_framework_tag = argv.flag?('framework')
32
- banner! if use_code_tag && use_framework_tag
32
+ banner! if (use_code_tag && use_framework_tag) || (!use_code_tag && !use_framework_tag && !argv.empty?)
33
33
 
34
34
  KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
35
35
  if Pod.match_version?('~> 1.11')
@@ -1,5 +1,5 @@
1
1
  module CocoapodsKz
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
4
4
 
5
5
  module Pod
@@ -20,18 +20,32 @@ module KZ
20
20
  # 检测是否有product名称相同的target
21
21
  temp_repeat_product_name = []
22
22
  @all_kz_pod_targets.each do |name, kz_pod_target|
23
- if temp_repeat_product_name.include?(kz_pod_target.product_name)
23
+ result = KZGlobalHelper.instance.pod_config_result_with_target(kz_pod_target)
24
+ if temp_repeat_product_name.include?("#{kz_pod_target.product_name}_#{kz_pod_target.platform_name}")
24
25
  kz_pod_target.product_name = "#{kz_pod_target.name}.framework"
25
26
  kz_pod_target.product_basename = kz_pod_target.name
26
- result = KZGlobalHelper.instance.pod_config_result_with_target(kz_pod_target)
27
27
  if result
28
- kz_pod_target.repair_modulemap_path = result.resource_path + kz_pod_target.product_name + "Modules/module.modulemap"
28
+ kz_pod_target.repair_modulemap_path = "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{kz_pod_target.root_name}/#{kz_pod_target.product_name}/Modules/module.modulemap"
29
+ if kz_pod_target.origin_uses_swift?
30
+ kz_pod_target.repair_swift_include_path = "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{kz_pod_target.root_name}/#{kz_pod_target.product_name}/Modules"
31
+ end
29
32
  else
30
- kz_pod_target.repair_modulemap_path = "${PODS_CONFIGURATION_BUILD_DIR}/#{kz_pod_target.name}/#{kz_pod_target.product_name}/Modules/module.modulemap"
33
+ kz_pod_target.repair_modulemap_path = "#{kz_pod_target.native_pod_target.configuration_build_dir}/#{kz_pod_target.product_name}/Modules/module.modulemap"
34
+ if kz_pod_target.origin_uses_swift?
35
+ kz_pod_target.repair_swift_include_path = "#{kz_pod_target.native_pod_target.configuration_build_dir}/#{kz_pod_target.product_name}/Modules"
36
+ end
31
37
  end
32
38
  kz_pod_target.need_repair_module_import = true
33
- elsif kz_pod_target.should_build?
34
- temp_repeat_product_name << kz_pod_target.product_name
39
+ elsif kz_pod_target.origin_should_build?
40
+ temp_repeat_product_name << "#{kz_pod_target.product_name}_#{kz_pod_target.platform_name}"
41
+ end
42
+
43
+ if kz_pod_target.force_load
44
+ if result
45
+ kz_pod_target.force_load_info = "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{kz_pod_target.root_name}/#{kz_pod_target.product_name}/#{kz_pod_target.product_basename}"
46
+ else
47
+ kz_pod_target.force_load_info = "#{kz_pod_target.configuration_build_dir(true)}/#{kz_pod_target.product_name}/#{kz_pod_target.product_basename}"
48
+ end
35
49
  end
36
50
  end
37
51
  end
@@ -30,7 +30,7 @@ module KZ
30
30
  next if framework_name == '.' || framework_name == '..' || framework_name == '.DS_Store'
31
31
 
32
32
  framework_path = @resource_path + framework_name
33
- if File.directory?(framework_path) && framework_name.end_with?(".framework")
33
+ if File.directory?(framework_path) && framework_name.end_with?(".xcframework")
34
34
  framework_paths << framework_path
35
35
  end
36
36
  end
@@ -35,7 +35,7 @@ module KZ
35
35
  Dir.foreach(version_folder) do |file_name|
36
36
  next if file_name == '.' || file_name == '..' || file_name == '.DS_Store'
37
37
 
38
- if file_name.end_with?(".framework") && File.directory?(version_folder + file_name)
38
+ if file_name.end_with?(".xcframework") && File.directory?(version_folder + file_name)
39
39
  have_framework = true
40
40
  break
41
41
  end
@@ -15,7 +15,7 @@ module KZ
15
15
 
16
16
  build_phase = native_target.new_shell_script_build_phase('[KZ] Generate Framework')
17
17
  build_phase.show_env_vars_in_log = '0'
18
- build_phase.output_paths = ['${KZ_FRAMEWORK_CACHE_PATH}/${FULL_PRODUCT_NAME}']
18
+ build_phase.output_paths = ['${KZ_FRAMEWORK_CACHE_PATH}/${PRODUCT_NAME}.xcframework']
19
19
  build_phase.shell_script = KZ.deal_path_for_xcconfig(KZ_GENERATOR_FRAMEWORK_PATH, true)
20
20
  end
21
21
 
@@ -34,6 +34,15 @@ module KZ
34
34
  xml_rule.script = KZ.deal_path_for_xcconfig(KZ_XML_BUILD_PATH, true)
35
35
  end
36
36
 
37
+ def add_force_load_exe_path_build_phase(native_target, output_path)
38
+ return if KZ::KZGlobalHelper.instance.disable_generate_framework
39
+
40
+ build_phase = native_target.new_shell_script_build_phase('[KZ] Froce Load File Output Path')
41
+ build_phase.show_env_vars_in_log = '0'
42
+ build_phase.output_paths = [output_path]
43
+ build_phase.shell_script = KZ.deal_path_for_xcconfig(KZ_FIX_FORCE_LOAD_EXE, true)
44
+ end
45
+
37
46
  def new_build_rule(project, native_target, name)
38
47
  new_rule = nil
39
48
  native_target.build_rules.each do |build_rule|
@@ -104,7 +113,7 @@ module KZ
104
113
  end
105
114
 
106
115
  # 添加私有头文件引用
107
- if kz_pod_target.should_build?
116
+ if kz_pod_target.current_should_build?
108
117
  private_hamp_info = private_hmap_info(kz_pod_target)
109
118
  if private_hamp_info.count > 0
110
119
  hmap_cache_path = kz_pod_target.pod_config_cache_path(false)
@@ -169,7 +178,7 @@ module KZ
169
178
  def private_hmap_info(kz_pod_target)
170
179
  header_paths = kz_pod_target.all_headers
171
180
  # 更新Headers
172
- if kz_pod_target.is_dev_pod && kz_pod_target.should_build?
181
+ if kz_pod_target.is_dev_pod
173
182
  header_paths.each do |header_pathname|
174
183
  symlink_path = kz_pod_target.local_private_headers_path + header_pathname.basename
175
184
  File.symlink(header_pathname, symlink_path) unless File.symlink?(symlink_path) || File.exist?(symlink_path)
@@ -196,7 +205,7 @@ module KZ
196
205
  hmap_info[kz_pod_target.product_basename + '/' + header_pathname_basename] = header_hmap_value_quotes
197
206
  end
198
207
 
199
- if kz_pod_target.uses_swift && kz_pod_target.is_dev_pod
208
+ if kz_pod_target.current_uses_swift? && kz_pod_target.is_dev_pod
200
209
  # 修改SPBoss-Swift.h文件的导入方式
201
210
  swift_bridge_file_name = "#{kz_pod_target.name}-Swift.h"
202
211
  hmap_info[swift_bridge_file_name] = { 'suffix' => swift_bridge_file_name, 'prefix' => "#{kz_pod_target.name}/" }
@@ -11,16 +11,18 @@ module KZ
11
11
  KZ_POD_CONFIG_ROOT = Pod::Config.instance.installation_root + 'Pods/KZPodConfigure'
12
12
  KZ_POD_CONFIG_SUPPORT_FILES = KZ_POD_CONFIG_ROOT + 'SupportFiles'
13
13
  KZ_POD_CONFIG_POD_TARGETS = KZ_POD_CONFIG_ROOT + 'PodTargets'
14
+ KZ_POD_CONFIG_POD_TEMPDIR = KZ_POD_CONFIG_ROOT + '.tempdir'
14
15
  KZ_POD_CONFIG_ROOT_STR = "${PODS_ROOT}/KZPodConfigure"
15
16
  # 修复pod lib报错问题
16
17
  Pod::Config.instance.installation_root = nil
17
18
 
18
19
  HMAP_EXECUTE_PATH = File.dirname(__FILE__) + '/../resources/hmap'
19
20
  FLEX_COMPLIER_PATH = KZ_POD_CONFIG_SUPPORT_FILES + 'FlexCompiler'
20
- KZ_MERGE_SWIFT_H_PATH = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_merge_swift_h.rb'
21
21
  KZ_GENERATOR_FRAMEWORK_PATH = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_generator_framework.sh'
22
22
  KZ_XML_BUILD_PATH = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_xml_build.sh'
23
23
  KZ_LOCK_FILE_PATH = KZ_POD_CONFIG_ROOT + 'KZConfigLock'
24
+ KZ_FIX_FORCE_LOAD_EXE = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_fix_force_load_exe.sh'
25
+ KZ_FEFRESH_PODS_PBXPROJ = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_refresh_pods_pbxproj.rb'
24
26
 
25
27
  def self.deal_path_for_xcconfig(path, add_quotes = false)
26
28
  if path.is_a?(String)
@@ -74,21 +76,24 @@ module KZ
74
76
  end
75
77
  FileUtils.mkdir_p(KZ_POD_CONFIG_SUPPORT_FILES) unless File.exist?(KZ_POD_CONFIG_SUPPORT_FILES)
76
78
  FileUtils.mkdir_p(KZ_POD_CONFIG_POD_TARGETS) unless File.exist?(KZ_POD_CONFIG_POD_TARGETS)
79
+ FileUtils.mkdir_p(KZ_POD_CONFIG_POD_TEMPDIR) unless File.exist?(KZ_POD_CONFIG_POD_TEMPDIR)
77
80
 
78
81
  FileUtils.rm(FLEX_COMPLIER_PATH) if File.exist?(FLEX_COMPLIER_PATH)
79
82
  FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler', FLEX_COMPLIER_PATH)
80
83
  system("chmod +x #{FLEX_COMPLIER_PATH}")
81
84
 
82
- FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_merge_swift_h.rb', KZ_MERGE_SWIFT_H_PATH)
83
-
84
85
  FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_generator_framework.sh', KZ_GENERATOR_FRAMEWORK_PATH)
85
86
  system("chmod +x #{KZ_GENERATOR_FRAMEWORK_PATH}")
86
87
 
87
88
  FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_xml_build.sh', KZ_XML_BUILD_PATH)
88
89
  system("chmod +x #{KZ_XML_BUILD_PATH}")
89
90
 
91
+ FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_fix_force_load_exe.sh', KZ_FIX_FORCE_LOAD_EXE)
92
+ system("chmod +x #{KZ_FIX_FORCE_LOAD_EXE}")
93
+
94
+ FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_refresh_pods_pbxproj.rb', KZ_FEFRESH_PODS_PBXPROJ)
95
+
90
96
  Pod::Config.instance.podfile.use_frameworks!(:linkage => :static)
91
- Pod::Config.instance.podfile.install!("cocoapods", :deterministic_uuids => false)
92
97
  else
93
98
  @kz_pod_enable = false
94
99
  @generate_kz_pod_targets = false
@@ -27,17 +27,25 @@ 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
+
41
49
  def initialize(native_pod_target)
42
50
  @native_pod_target = native_pod_target
43
51
  @name = native_pod_target.name
@@ -49,10 +57,13 @@ module KZ
49
57
  @is_dev_pod = false
50
58
  @config_pod_mode = :kz_pod_origin_mode
51
59
 
60
+ @platform_name = native_pod_target.platform.symbolic_name
52
61
  @product_name = native_pod_target.origin_product_name
53
62
  @product_basename = native_pod_target.origin_product_basename
54
63
  @need_repair_module_import = false
55
64
  @use_local_private_headers_path = false
65
+ @force_load = false
66
+ @use_modulemap = true
56
67
 
57
68
  native_pod_target.file_accessors.each do |file_accessor|
58
69
  file_accessor.kz_pod_target = self
@@ -66,7 +77,6 @@ module KZ
66
77
  end
67
78
 
68
79
  def all_headers
69
- return [] unless have_download_pod?
70
80
  @all_headers ||= begin
71
81
  all_headers = []
72
82
  native_pod_target.file_accessors.each do |file_accessor|
@@ -79,8 +89,6 @@ module KZ
79
89
  end
80
90
 
81
91
  def public_headers
82
- return [] unless have_download_pod?
83
-
84
92
  @public_headers ||= begin
85
93
  public_headers = []
86
94
  native_pod_target.file_accessors.each do |file_accessor|
@@ -142,6 +150,17 @@ module KZ
142
150
  @repair_import << kz_repair_pod_target if kz_repair_pod_target
143
151
  end
144
152
  end
153
+
154
+ force_load = pod_config[:force_load]
155
+ if force_load.is_a?(TrueClass)
156
+ @force_load = true
157
+ end
158
+
159
+ use_modulemap = pod_config[:use_modulemap]
160
+ if use_modulemap.is_a?(FalseClass)
161
+ @use_modulemap = false
162
+ end
163
+
145
164
  end
146
165
 
147
166
  # 在当前target的所有依赖中,过滤有有修补的target
@@ -242,23 +261,58 @@ module KZ
242
261
  all_repair_modulemap_paths
243
262
  end
244
263
 
264
+ def all_repair_swift_include_paths
265
+ all_repair_swift_include_paths = []
266
+ all_repair_swift_include_paths << repair_swift_include_path if self.repair_swift_include_path
267
+ recursive_dependent_targets.each do |recursive_dependent_target|
268
+ all_repair_swift_include_paths.concat(recursive_dependent_target.all_repair_swift_include_paths)
269
+ end
270
+ all_repair_swift_include_paths.uniq! if all_repair_swift_include_paths.count > 0
271
+ all_repair_swift_include_paths
272
+ end
273
+
245
274
  def prefix_header_path
246
275
  @native_pod_target.prefix_header_path
247
276
  end
248
277
 
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)
278
+ # 当前pod是否存在可编译的文件,配置framework后当前pod就不存在可编译文件
279
+ def current_should_build?
280
+ @native_pod_target.should_build?
252
281
  end
253
282
 
254
- def should_build?
255
- have_download_pod? ? @native_pod_target.should_build? : false
283
+ # 原pod是否存在可编译的文件
284
+ def origin_should_build?
285
+ return @origin_should_build if defined? @origin_should_build
286
+ accessors = @native_pod_target.file_accessors.select { |fa| fa.spec.library_specification? }
287
+ all_origin_compile_files = []
288
+ accessors.each do |accessor|
289
+ all_origin_compile_files.concat(accessor.origin_source_files - accessor.kz_headers)
290
+ end
291
+ @origin_should_build = !all_origin_compile_files.empty?
256
292
  end
257
293
 
258
- def uses_swift?
294
+ def current_uses_swift?
259
295
  @native_pod_target.uses_swift?
260
296
  end
261
297
 
298
+ def origin_uses_swift?
299
+ return @uses_swift if defined? @uses_swift
300
+ @uses_swift = (!origin_should_build? && !@native_pod_target.spec_swift_versions.empty?) ||
301
+ @native_pod_target.file_accessors.select { |a| a.spec.library_specification? }.any? do |file_accessor|
302
+ uses_swift_for_spec?(file_accessor.spec)
303
+ end
304
+ end
305
+
306
+ def uses_swift_for_spec?(spec)
307
+ @uses_swift_for_spec_cache ||= {}
308
+ return @uses_swift_for_spec_cache[spec.name] if @uses_swift_for_spec_cache.key?(spec.name)
309
+ @uses_swift_for_spec_cache[spec.name] = begin
310
+ file_accessor = @native_pod_target.file_accessors.find { |fa| fa.spec == spec }
311
+ raise "[Bug] Unable to find file accessor for spec `#{spec.inspect}` in pod target `#{label}`" unless file_accessor
312
+ file_accessor.origin_source_files.any? { |sf| sf.extname == '.swift' }
313
+ end
314
+ end
315
+
262
316
  def local_private_headers_path
263
317
  @local_private_headers_path ||= begin
264
318
  path = KZ_POD_CONFIG_POD_TARGETS + @name + "Headers"
@@ -267,5 +321,12 @@ module KZ
267
321
  end
268
322
  end
269
323
 
324
+ def configuration_build_dir(for_froce_load = false)
325
+ if for_froce_load
326
+ return @native_pod_target.configuration_build_dir + "/.force_load"
327
+ end
328
+ @native_pod_target.configuration_build_dir
329
+ end
330
+
270
331
  end
271
332
  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
 
@@ -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,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,6 +28,11 @@ 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
@@ -47,9 +52,12 @@ module Pod
47
52
  xcconfig.attributes['USE_HEADERMAP'] = 'NO'
48
53
  framework_cache_path = KZ.deal_path_for_xcconfig(kz_pod_target.pod_config_cache_path(true))
49
54
  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)
55
+ if kz_pod_target.force_load
56
+ xcconfig.attributes['KZ_FIX_FORCE_LOAD_EXE_FOLDER'] = kz_pod_target.configuration_build_dir(true)
57
+ end
51
58
 
52
- add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths, kz_pod_target.uses_swift?)
59
+ add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths, kz_pod_target.current_uses_swift?)
60
+ add_repair_swift_include_path(xcconfig, kz_pod_target.all_repair_swift_include_paths, kz_pod_target.current_uses_swift?)
53
61
  kz_update_xcconfig_file(xcconfig, path)
54
62
  return
55
63
  end
@@ -74,6 +82,18 @@ module Pod
74
82
  end
75
83
  end
76
84
 
85
+ def add_repair_swift_include_path(xcconfig, repair_swift_include_paths, uses_swift)
86
+ # 只有当前pod支持swift,才需要所依赖的pod提供的swiftmodule
87
+ if repair_swift_include_paths.count > 0 && uses_swift
88
+ repair_swift_include_paths.each do |repair_swift_include_path|
89
+ swift_include_path = ' ' + KZ.deal_path_for_xcconfig(repair_swift_include_path, true)
90
+ unless xcconfig.attributes['SWIFT_INCLUDE_PATHS'].include?(swift_include_path)
91
+ xcconfig.attributes['SWIFT_INCLUDE_PATHS'] += swift_include_path
92
+ end
93
+ end
94
+ end
95
+ end
96
+
77
97
  def kz_update_xcconfig_file(xcconfig, path)
78
98
  if path.exist?
79
99
  contents = xcconfig.to_s
@@ -106,6 +126,15 @@ module Pod
106
126
  xcconfig.attributes['OTHER_CFLAGS'] = new_flags.join(' ')
107
127
  end
108
128
 
129
+ def kz_add_force_load_tag(xcconfig, kz_pod_target)
130
+ other_linker_flags = xcconfig.other_linker_flags
131
+ frameworks_flags = other_linker_flags[:frameworks]
132
+ force_flags = other_linker_flags[:force_load]
133
+
134
+ frameworks_flags.delete(kz_pod_target.product_basename)
135
+ force_flags.add(KZ.deal_path_for_xcconfig(kz_pod_target.force_load_info, true))
136
+ end
137
+
109
138
  end
110
139
  end
111
140
  end
@@ -5,11 +5,11 @@ 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
15
  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,15 @@
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
+ xcode_running = system("ps aux | grep '[X]code' > /dev/null 2>&1")
12
+ if xcode_running
13
+ system("touch #{current_pods_pbxproj_path}")
14
+ end
15
+
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.10
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-20 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
@@ -63,19 +64,20 @@ files:
63
64
  - lib/cocoapods-kz/helpers/repair_module_import.rb
64
65
  - lib/cocoapods-kz/native.rb
65
66
  - lib/cocoapods-kz/native/acknowledgements.rb
66
- - lib/cocoapods-kz/native/analyzer.rb
67
67
  - lib/cocoapods-kz/native/dls.rb
68
68
  - lib/cocoapods-kz/native/file_accessor.rb
69
69
  - lib/cocoapods-kz/native/installer.rb
70
70
  - lib/cocoapods-kz/native/pod_target.rb
71
71
  - lib/cocoapods-kz/native/pod_target_installer.rb
72
+ - lib/cocoapods-kz/native/pods_project_writer.rb
72
73
  - lib/cocoapods-kz/native/specification.rb
73
74
  - lib/cocoapods-kz/native/target.rb
74
75
  - lib/cocoapods-kz/native/target_installer_helper.rb
75
76
  - lib/cocoapods-kz/resources/FlexCompiler
76
77
  - lib/cocoapods-kz/resources/hmap
78
+ - lib/cocoapods-kz/resources/kz_fix_force_load_exe.sh
77
79
  - lib/cocoapods-kz/resources/kz_generator_framework.sh
78
- - lib/cocoapods-kz/resources/kz_merge_swift_h.rb
80
+ - lib/cocoapods-kz/resources/kz_refresh_pods_pbxproj.rb
79
81
  - lib/cocoapods-kz/resources/kz_xml_build.sh
80
82
  - lib/cocoapods_plugin.rb
81
83
  homepage: https://github.com/EXAMPLE/cocoapods-kz
@@ -1,23 +0,0 @@
1
- require 'cocoapods-kz/helpers/kz_global_helper'
2
- require 'cocoapods-kz/helpers/kz_generator'
3
-
4
- module Pod
5
- class Installer
6
- class Analyzer
7
- alias_method :original_generate_targets, :generate_targets
8
-
9
- def generate_targets(resolver_specs_by_target, target_inspections)
10
- aggregate_targets, pod_targets = original_generate_targets(resolver_specs_by_target, target_inspections)
11
- if KZ::KZGlobalHelper.instance.generate_kz_pod_targets
12
- main_project = aggregate_targets.first.user_project
13
- kz_analyer = KZ::KZAnalyzer.new(pod_targets, self.sandbox.development_pods)
14
- kz_analyer.analyer
15
- KZ::KZGlobalHelper.instance.kz_analyzer = kz_analyer
16
- KZ::KZGlobalHelper.instance.kz_generator = KZ::KZGenerator.new(main_project)
17
- end
18
- [aggregate_targets, pod_targets]
19
- end
20
-
21
- end
22
- end
23
- end
@@ -1,14 +0,0 @@
1
- require 'fileutils'
2
- require 'pathname'
3
-
4
- product_swift_h_path = Pathname.new(ARGV[0])
5
- product_simulator_swift_h_path = Pathname.new(ARGV[1])
6
- target_swfit_h_path = Pathname.new(ARGV[2])
7
-
8
- if File.exist?(product_swift_h_path) && File.exist?(product_simulator_swift_h_path)
9
- FileUtils.cp_r(product_swift_h_path, target_swfit_h_path)
10
- replacement = File.read(product_simulator_swift_h_path)
11
- content_a = File.read(target_swfit_h_path)
12
- content_a.gsub!("#error unsupported Swift architecture", replacement)
13
- File.write(target_swfit_h_path, content_a)
14
- end