cocoapods-kz 0.0.10 → 0.0.13

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 (28) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-kz/command/clean.rb +30 -23
  3. data/lib/cocoapods-kz/command/install.rb +13 -3
  4. data/lib/cocoapods-kz/command/update.rb +13 -3
  5. data/lib/cocoapods-kz/gem_version.rb +1 -1
  6. data/lib/cocoapods-kz/helpers/kz_framework_manager.rb +169 -1
  7. data/lib/cocoapods-kz/helpers/kz_generator.rb +370 -39
  8. data/lib/cocoapods-kz/helpers/kz_global_helper.rb +28 -1
  9. data/lib/cocoapods-kz/helpers/kz_log.rb +11 -0
  10. data/lib/cocoapods-kz/helpers/kz_pod_target.rb +26 -6
  11. data/lib/cocoapods-kz/native/dls.rb +10 -0
  12. data/lib/cocoapods-kz/native/dsl_spec.rb +7 -0
  13. data/lib/cocoapods-kz/native/file_accessor.rb +8 -3
  14. data/lib/cocoapods-kz/native/installer.rb +3 -0
  15. data/lib/cocoapods-kz/native/pod_target_installer.rb +23 -0
  16. data/lib/cocoapods-kz/native/pod_target_integrator.rb +62 -0
  17. data/lib/cocoapods-kz/native/target_installer_helper.rb +40 -0
  18. data/lib/cocoapods-kz/native/target_integrator.rb +34 -0
  19. data/lib/cocoapods-kz/native.rb +2 -0
  20. data/lib/cocoapods-kz/resources/arm64ToSimulator +0 -0
  21. data/lib/cocoapods-kz/resources/kz_generator_framework.sh +6 -2
  22. data/lib/cocoapods-kz/resources/kz_improve_custom_yaml.sh +25 -0
  23. data/lib/cocoapods-kz/resources/kz_refresh_pods_pbxproj.rb +10 -6
  24. data/lib/cocoapods-kz/resources/on_demand_resources/kz_complete_asset_pack_output_spec_plist.rb +26 -0
  25. data/lib/cocoapods-kz/resources/on_demand_resources/kz_create_asset_pack_manifest_plist.rb +44 -0
  26. data/lib/cocoapods-kz/resources/on_demand_resources/kz_create_on_demand_resources_plis.rb +26 -0
  27. data/lib/cocoapods-kz/resources/on_demand_resources/kz_on_demand_resources_xocde.sh +162 -0
  28. metadata +13 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f2ecfbcbc07e3ac505466898ae1b82fe6daf936bcfc56d7a128c7256a000888
4
- data.tar.gz: '07248a9d57a52e6f2948b2d893d7463d8581f90d4bf29104df5d3465f991355c'
3
+ metadata.gz: 60b78485f551ed394bb167d18aad9e08008ea9c432ef555ade88cfc241f918bb
4
+ data.tar.gz: '082f62c4d943cde90357a9a5a55c10636a39ad232e9aded7230170301c01453e'
5
5
  SHA512:
6
- metadata.gz: b32004addf7c59b259281c83d92fab22dc85d5e7f021992f9a3a86af996d8c3de764885fc6bf8b44b2094716743d9cb45133398f4468733c95def92fba911886
7
- data.tar.gz: 4552647daba1c5c5265bc67302e84788a17bed18d6d87c93e70f90c6d3e97d393c342f6109f1f2f43e3a82ad3ab7071168e39df64b4b9ab35f9b3a308d6a06a8
6
+ metadata.gz: ea906c0ac96d2c98a2eab4631a356cb1753de215ca0c0694cd13af454b3418f96f1fe4400d081c63f69115c6870efabdd146ef839168cdaa8d9de2ba3e2bdc6d
7
+ data.tar.gz: 295dec357984a4e81fea271b0b261af9e0dc6a0e383d048df8e46224521d3e77ee58124116b0e0d42731121af35d8d4234b92b63c51ca0fc26028e714cba830a
@@ -7,8 +7,7 @@ module Pod
7
7
  self.summary = 'pod kz clean 用于清理缓存以一些报错文件'
8
8
 
9
9
  self.description = <<-DESC
10
- 在pod update过程中由于代码变动,module缓存容易产生签名过期的问题,部分属性文件,跳转也会存在路径不对的情况,需要清理老旧缓存文件,
11
- 让Xcode重新生成
10
+ 在pod update过程中由于代码变动,module缓存容易产生签名过期的问题,部分属性文件,跳转也会存在路径不对的情况,需要清理老旧缓存文件,让Xcode重新生成
12
11
  DESC
13
12
 
14
13
  self.arguments = [
@@ -17,42 +16,50 @@ module Pod
17
16
 
18
17
  def self.options
19
18
  [
20
- %w[--xcode 清除module缓存与头文件索引问题],
19
+ ["--xcode", "清除module缓存与头文件索引问题"],
20
+ ["--framework", "清除所有自生成本地缓存的framework"],
21
21
  ]
22
22
  end
23
23
 
24
24
  def initialize(argv)
25
- clean_xcode = argv.flag?('xcode')
26
- banner! unless clean_xcode
25
+ @clean_xcode = argv.flag?('xcode')
26
+ @clean_framework = argv.flag?('framework')
27
+ banner! unless @clean_xcode || @clean_framework
27
28
 
28
29
  super
29
30
  end
30
31
 
31
32
  def run
32
- xcodeproj_path = Pathname.new(Dir[Pod::Config.instance.installation_root + "*.xcodeproj"].first)
33
- return unless xcodeproj_path
33
+ if @clean_xcode
34
+ xcodeproj_path = Pathname.new(Dir[Pod::Config.instance.installation_root + "*.xcodeproj"].first)
35
+ return unless xcodeproj_path
34
36
 
35
- xcode_derived_data_path = Pathname.new(Dir.home + "/Library/Developer/Xcode/DerivedData")
36
- module_cache_noindex_path = xcode_derived_data_path + "ModuleCache.noindex"
37
- FileUtils.rm_rf(module_cache_noindex_path) if module_cache_noindex_path.exist?
37
+ xcode_derived_data_path = Pathname.new(Dir.home + "/Library/Developer/Xcode/DerivedData")
38
+ module_cache_noindex_path = xcode_derived_data_path + "ModuleCache.noindex"
39
+ FileUtils.rm_rf(module_cache_noindex_path) if module_cache_noindex_path.exist?
38
40
 
39
- project_name = xcodeproj_path.basename.to_s.split(".").first
40
- Dir.foreach(xcode_derived_data_path) do |file_name|
41
- next if file_name == '.' || file_name == '..' || file_name == '.DS_Store'
41
+ project_name = xcodeproj_path.basename.to_s.split(".").first
42
+ Dir.foreach(xcode_derived_data_path) do |file_name|
43
+ next if file_name == '.' || file_name == '..' || file_name == '.DS_Store'
42
44
 
43
- if file_name.start_with?(project_name)
44
- project_path = xcode_derived_data_path + file_name
45
- index_noindex_path = project_path + "Index.noindex"
46
- FileUtils.rm_rf(index_noindex_path) if index_noindex_path.exist?
45
+ if file_name.start_with?(project_name)
46
+ project_path = xcode_derived_data_path + file_name
47
+ index_noindex_path = project_path + "Index.noindex"
48
+ FileUtils.rm_rf(index_noindex_path) if index_noindex_path.exist?
49
+ end
50
+ end
51
+
52
+ default_xcode_path = Pathname.new('/Applications/Xcode.app')
53
+ if default_xcode_path.exist?
54
+ system("osascript -e 'quit app \"Xcode\"'")
55
+ sleep 1
56
+ workspace_path = Dir[Pod::Config.instance.installation_root + "*.xcworkspace"].first
57
+ system("open \"#{workspace_path}\"")
47
58
  end
48
59
  end
49
60
 
50
- default_xcode_path = Pathname.new('/Applications/Xcode.app')
51
- if default_xcode_path.exist?
52
- system("osascript -e 'quit app \"Xcode\"'")
53
- sleep 1
54
- workspace_path = Dir[Pod::Config.instance.installation_root + "*.xcworkspace"].first
55
- system("open \"#{workspace_path}\"")
61
+ if @clean_framework
62
+ FileUtils.rm_r(KZ::KZ_POD_CONFIG_ROOT) if File.exist?(KZ::KZ_POD_CONFIG_ROOT)
56
63
  end
57
64
  end
58
65
  end
@@ -22,14 +22,16 @@ module Pod
22
22
  ['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
23
23
  ['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
24
24
  ['--debug', "debug模式,会打印调试日志或生成调试文件"],
25
- ['--no-framework-update', "build后不再生成frameowrk"]
25
+ ['--framework-update', "build后不再生成frameowrk"],
26
+ ['--arm64-simulator', "适配模拟器的arm64模式,会自动将只支持真机arm64的framework转成arm64模式"]
26
27
  ].concat(super).reject { |(name, _)| name == '--no-repo-update' }
27
28
  end
28
29
 
29
30
  def initialize(argv)
30
31
  use_code_tag = argv.flag?('code')
31
32
  use_framework_tag = argv.flag?('framework')
32
- banner! if (use_code_tag && use_framework_tag) || (!use_code_tag && !use_framework_tag && !argv.empty?)
33
+ banner! unless isOptionsArgvFlag(argv.options.keys)
34
+ banner! if (use_code_tag && use_framework_tag)
33
35
 
34
36
  KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
35
37
  if Pod.match_version?('~> 1.11')
@@ -37,12 +39,20 @@ module Pod
37
39
  KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
38
40
  end
39
41
  KZ::KZGlobalHelper.instance.debug = true if argv.flag?('debug')
40
- KZ::KZGlobalHelper.instance.disable_generate_framework = true if argv.flag?('framework-update') != nil
42
+ KZ::KZGlobalHelper.instance.arm64_simulator = true if argv.flag?('arm64-simulator')
43
+ framework_update = argv.flag?('framework-update')
44
+ KZ::KZGlobalHelper.instance.disable_generate_framework = true if (framework_update != nil && framework_update == false)
41
45
 
42
46
  super
43
47
  @additional_args = argv.remainder!
44
48
  end
45
49
 
50
+ def isOptionsArgvFlag(all_flags)
51
+ return true if all_flags.empty?
52
+ supported_flags = ["repo-update", "deployment", "clean-install", "code", "framework", "debug", "framework-update", "arm64-simulator"]
53
+ return (all_flags & supported_flags) == all_flags
54
+ end
55
+
46
56
  def run
47
57
  KZ::KZGlobalHelper.instance.prepare
48
58
  install = Pod::Command::Install.new(CLAide::ARGV.new([*@additional_args]))
@@ -22,14 +22,16 @@ module Pod
22
22
  ['--framework', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
23
23
  ['--code', "后面需要跟上pod名(多个pod,使用英文逗号隔开),支持追加*匹配任意内容"],
24
24
  ['--debug', "debug模式,会打印调试日志或生成调试文件"],
25
- ['--no-framework-update', "build后不再生成frameowrk"]
25
+ ['--no-framework-update', "build后不再生成frameowrk"],
26
+ ['--arm64-simulator', "适配模拟器的arm64模式,会自动将只支持真机arm64的framework转成arm64模式"]
26
27
  ].concat(super)
27
28
  end
28
29
 
29
30
  def initialize(argv)
30
31
  use_code_tag = argv.flag?('code')
31
32
  use_framework_tag = argv.flag?('framework')
32
- banner! if (use_code_tag && use_framework_tag) || (!use_code_tag && !use_framework_tag && !argv.empty?)
33
+ banner! unless isOptionsArgvFlag(argv.options.keys)
34
+ banner! if (use_code_tag && use_framework_tag)
33
35
 
34
36
  KZ::KZGlobalHelper.instance.analyze_special_parameters(use_code_tag, use_framework_tag, argv.arguments!)
35
37
  if Pod.match_version?('~> 1.11')
@@ -37,12 +39,20 @@ module Pod
37
39
  KZ::KZGlobalHelper.instance.generate_kz_pod_targets = true
38
40
  end
39
41
  KZ::KZGlobalHelper.instance.debug = true if argv.flag?('debug')
40
- KZ::KZGlobalHelper.instance.disable_generate_framework = true if argv.flag?('framework-update') != nil
42
+ KZ::KZGlobalHelper.instance.arm64_simulator = true if argv.flag?('arm64-simulator')
43
+ framework_update = argv.flag?('framework-update')
44
+ KZ::KZGlobalHelper.instance.disable_generate_framework = true if (framework_update != nil && framework_update == false)
41
45
 
42
46
  super
43
47
  @additional_args = argv.remainder!
44
48
  end
45
49
 
50
+ def isOptionsArgvFlag(all_flags)
51
+ return true if all_flags.empty?
52
+ supported_flags = ["sources", "exclude-pods", "clean-install", "code", "framework", "debug", "framework-update", "arm64-simulator"]
53
+ return (all_flags & supported_flags) == all_flags
54
+ end
55
+
46
56
  def run
47
57
  KZ::KZGlobalHelper.instance.prepare
48
58
  update = Pod::Command::Update.new(CLAide::ARGV.new([*@additional_args]))
@@ -1,5 +1,5 @@
1
1
  module CocoapodsKz
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.13"
3
3
  end
4
4
 
5
5
  module Pod
@@ -1,6 +1,8 @@
1
1
  require_relative 'kz_pod_target'
2
2
  require_relative 'kz_global_helper'
3
3
  require_relative 'kz_config_result'
4
+ require 'tmpdir'
5
+ require_relative 'kz_log'
4
6
 
5
7
  module KZ
6
8
  class KZFrameworkManager
@@ -27,7 +29,7 @@ module KZ
27
29
  config_folder = KZ_POD_CONFIG_POD_TARGETS + folder_name
28
30
  if File.directory?(config_folder)
29
31
  Dir.foreach(config_folder) do |version|
30
- next if version == '.' || version == '..' || version == '.DS_Store'
32
+ next if version == '.' || version == '..' || version == '.DS_Store' || version == 'Headers'
31
33
 
32
34
  version_folder = config_folder + version
33
35
  if File.directory?(version_folder)
@@ -48,5 +50,171 @@ module KZ
48
50
  @@all_resources_cache_info
49
51
  end
50
52
 
53
+ def self.handle_origin_framework(origin_frameworks, kz_pod_target)
54
+ new_frameworks = []
55
+ old_destination_path = kz_pod_target.pod_config_cache_path(false , true)
56
+ FileUtils.rm_rf(old_destination_path) if File.exist?(old_destination_path)
57
+
58
+ destination_path = kz_pod_target.pod_config_cache_path(true, true)
59
+ origin_frameworks.each do |origin_framework_path|
60
+ if kz_pod_target.disable_to_simulator_frameworks.include?(origin_framework_path)
61
+ new_frameworks.append(origin_framework_path)
62
+ else
63
+ new_framework_path = self.convert_arm64_to_simulator(origin_framework_path, destination_path)
64
+ if new_framework_path == origin_framework_path
65
+ kz_pod_target.disable_to_simulator_frameworks.append(origin_framework_path)
66
+ end
67
+ new_frameworks.append(new_framework_path)
68
+ end
69
+ end
70
+ new_frameworks
71
+ end
72
+
73
+ def self.convert_arm64_to_simulator(origin_framework_path, destination_path)
74
+ framework_name = origin_framework_path.basename.to_s
75
+ if framework_name.end_with?(".framework")
76
+ framework_basename = framework_name.chomp(".framework")
77
+ xcframework_path = destination_path + "#{framework_basename}.xcframework"
78
+ return xcframework_path if File.exist?(xcframework_path) && !Dir.empty?(xcframework_path)
79
+
80
+ if self.create_xcframework(origin_framework_path, origin_framework_path, framework_basename, xcframework_path)
81
+ return xcframework_path
82
+ else
83
+ return origin_framework_path
84
+ end
85
+ elsif framework_name.end_with?(".xcframework")
86
+ framework_basename = framework_name.chomp(".xcframework")
87
+ xcframework_path = destination_path + "#{framework_basename}.xcframework"
88
+ return xcframework_path if File.exist?(xcframework_path)
89
+
90
+ info_plist_path = origin_framework_path + "Info.plist"
91
+ return origin_framework_path unless File.exist?(info_plist_path)
92
+
93
+ info_plist = Xcodeproj::Plist.read_from_path(info_plist_path)
94
+ available_libraries = info_plist["AvailableLibraries"]
95
+ available_libraries.each do |available_librarie|
96
+ if available_librarie["SupportedPlatformVariant"] == "simulator" && available_librarie["SupportedArchitectures"].include?("arm64")
97
+ return origin_framework_path
98
+ end
99
+ end
100
+
101
+ # 找到真机arm64 framework与模拟器x86_64 framework
102
+ xc_framework_path = ""
103
+ xc_simulator_framework_path = ""
104
+ available_libraries.each do |available_librarie|
105
+ if available_librarie["SupportedPlatformVariant"] == "simulator"
106
+ if available_librarie["SupportedArchitectures"].include?("x86_64")
107
+ xc_simulator_framework_path = origin_framework_path + available_librarie["LibraryIdentifier"] + available_librarie["LibraryPath"]
108
+ end
109
+ elsif available_librarie["SupportedPlatform"] == "ios"
110
+ if available_librarie["SupportedArchitectures"].include?("arm64")
111
+ xc_framework_path = origin_framework_path + available_librarie["LibraryIdentifier"] + available_librarie["LibraryPath"]
112
+ end
113
+ end
114
+ end
115
+
116
+ xc_simulator_framework_path = xc_framework_path unless xc_simulator_framework_path != ""
117
+ if self.create_xcframework(xc_framework_path, xc_simulator_framework_path, framework_basename, xcframework_path)
118
+ return xcframework_path
119
+ else
120
+ return origin_framework_path
121
+ end
122
+ else
123
+ return origin_framework_path
124
+ end
125
+ end
126
+
127
+ def self.create_xcframework(origin_framework_path, origin_simulator_framework_path, framework_basename, destination_xcframework_path)
128
+ tempdir = Pathname(Dir.mktmpdir)
129
+ arm64_path = tempdir + "arm64"
130
+ FileUtils.mkdir_p(arm64_path)
131
+ arm64_framework_path = arm64_path + "#{framework_basename}.framework"
132
+ FileUtils.cp_r(origin_framework_path, arm64_framework_path)
133
+ arm64_framework_exe_path = arm64_framework_path + framework_basename
134
+ if self.contain_multiple_arch?(arm64_framework_exe_path)
135
+ system("lipo #{arm64_framework_exe_path} -thin arm64 -output #{arm64_framework_exe_path} #{KZGlobalHelper.instance.debug_shell_log_tag}")
136
+ end
137
+
138
+ simulator_path = tempdir + "simulator"
139
+ FileUtils.mkdir_p(simulator_path)
140
+ simulator_framework_path = simulator_path + "#{framework_basename}.framework"
141
+ FileUtils.cp_r(origin_simulator_framework_path, simulator_framework_path)
142
+ simulator_framework_exe_path = simulator_framework_path + framework_basename
143
+ contain_x8664 = self.contain_x8664?(simulator_framework_exe_path)
144
+ if contain_x8664
145
+ system("lipo #{simulator_framework_exe_path} -thin x86_64 -output #{simulator_framework_exe_path} #{KZGlobalHelper.instance.debug_shell_log_tag}")
146
+ else
147
+ FileUtils.rm(simulator_framework_exe_path)
148
+ end
149
+
150
+ temp_framwork_exe_path = tempdir + "#{framework_basename}_arm64_simulator"
151
+ if self.is_dynamic_library?(origin_framework_path + framework_basename)
152
+ xcrun_vtool_show_result = `xcrun vtool -arch arm64 -show #{origin_framework_path + framework_basename}`.lines.map(&:chomp)
153
+ framework_sdk_version = "16.0"
154
+ framework_deployment_version = "12.0"
155
+ reach_cmd_tag = false
156
+ xcrun_vtool_show_result.each do |line|
157
+ reach_cmd_tag = false if line.start_with?("Load command")
158
+
159
+ line_infos = line.lstrip.split
160
+ next unless line_infos.count == 2
161
+
162
+ if line_infos.first == "cmd" && line_infos.last == "LC_VERSION_MIN_IPHONEOS"
163
+ reach_cmd_tag = true
164
+ end
165
+
166
+ if reach_cmd_tag
167
+ if line_infos.include?("sdk")
168
+ framework_sdk_version = line_infos.last
169
+ elsif line_infos.include?("version")
170
+ framework_deployment_version = line_infos.last
171
+ end
172
+ end
173
+ end
174
+ xcrun_vtool_set_result = system("xcrun vtool -arch arm64 -set-build-version 7 #{framework_deployment_version} #{framework_sdk_version} -replace -output #{temp_framwork_exe_path} #{arm64_framework_exe_path}")
175
+ unless xcrun_vtool_set_result
176
+ FileUtils.rm_r(tempdir)
177
+ return false
178
+ end
179
+ else
180
+ ar_x_path = tempdir + "ar_x"
181
+ FileUtils.mkdir_p(ar_x_path)
182
+ ar_x_success = system("cd #{ar_x_path}; ar x #{arm64_framework_exe_path}")
183
+ if ar_x_success
184
+ system("for file in #{ar_x_path}/*.o; do #{ARM64_TO_SIMULATOR_EXECUTE_PATH} $file; done")
185
+ system("ar crv #{temp_framwork_exe_path} #{ar_x_path}/*.o &> /dev/null")
186
+ else
187
+ FileUtils.rm_r(tempdir)
188
+ return false
189
+ end
190
+ end
191
+
192
+ if contain_x8664
193
+ system("lipo -create #{temp_framwork_exe_path} #{simulator_framework_exe_path} -output #{simulator_framework_exe_path} #{KZGlobalHelper.instance.debug_shell_log_tag}")
194
+ else
195
+ FileUtils.mv("#{temp_framwork_exe_path}", simulator_framework_exe_path)
196
+ end
197
+ FileUtils.mkdir_p(destination_xcframework_path) unless File.exist?(destination_xcframework_path)
198
+ system("xcodebuild -create-xcframework -framework $(readlink -f '#{arm64_framework_path}') -framework $(readlink -f '#{simulator_framework_path}') -output #{destination_xcframework_path} #{KZGlobalHelper.instance.debug_shell_log_tag}")
199
+ FileUtils.rm_r(tempdir)
200
+
201
+ return true
202
+ end
203
+
204
+ def self.is_dynamic_library?(file_path)
205
+ file_result = `file -b #{file_path}`
206
+ return file_result.include?("dynamically linked shared library")
207
+ end
208
+
209
+ def self.contain_x8664?(file_path)
210
+ file_result = `file -b #{file_path}`
211
+ return file_result.include?("for architecture x86_64")
212
+ end
213
+
214
+ def self.contain_multiple_arch?(file_path)
215
+ file_result = `lipo -info #{file_path}`
216
+ return file_result.include?("Architectures in the fat file")
217
+ end
218
+
51
219
  end
52
220
  end