cocoapods-kz 0.0.11 → 0.0.14
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.
- checksums.yaml +4 -4
- data/lib/cocoapods-kz/gem_version.rb +1 -1
- data/lib/cocoapods-kz/helpers/kz_analyzer.rb +23 -0
- data/lib/cocoapods-kz/helpers/kz_framework_manager.rb +29 -4
- data/lib/cocoapods-kz/helpers/kz_generator.rb +364 -38
- data/lib/cocoapods-kz/helpers/kz_global_helper.rb +32 -6
- data/lib/cocoapods-kz/helpers/kz_pod_target.rb +24 -2
- data/lib/cocoapods-kz/native/dls.rb +10 -0
- data/lib/cocoapods-kz/native/dsl_spec.rb +7 -0
- data/lib/cocoapods-kz/native/file_accessor.rb +25 -5
- data/lib/cocoapods-kz/native/installer.rb +4 -0
- data/lib/cocoapods-kz/native/pod_target_installer.rb +23 -0
- data/lib/cocoapods-kz/native/target_installer_helper.rb +52 -0
- data/lib/cocoapods-kz/native/target_integrator.rb +34 -0
- data/lib/cocoapods-kz/native.rb +1 -0
- data/lib/cocoapods-kz/resources/FlexCompiler_V1 +0 -0
- data/lib/cocoapods-kz/resources/arm64ToSimulator +0 -0
- data/lib/cocoapods-kz/resources/kz_generator_framework.sh +6 -2
- data/lib/cocoapods-kz/resources/kz_improve_custom_yaml.sh +25 -0
- data/lib/cocoapods-kz/resources/kz_refresh_pods_pbxproj.rb +9 -7
- data/lib/cocoapods-kz/resources/on_demand_resources/kz_complete_asset_pack_output_spec_plist.rb +26 -0
- data/lib/cocoapods-kz/resources/on_demand_resources/kz_create_asset_pack_manifest_plist.rb +44 -0
- data/lib/cocoapods-kz/resources/on_demand_resources/kz_create_on_demand_resources_plis.rb +26 -0
- data/lib/cocoapods-kz/resources/on_demand_resources/kz_on_demand_resources_xocde.sh +162 -0
- metadata +11 -3
@@ -24,6 +24,10 @@ module KZ
|
|
24
24
|
KZ_LOCK_FILE_PATH = KZ_POD_CONFIG_ROOT + 'KZConfigLock'
|
25
25
|
KZ_FIX_FORCE_LOAD_EXE = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_fix_force_load_exe.sh'
|
26
26
|
KZ_FEFRESH_PODS_PBXPROJ = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_refresh_pods_pbxproj.rb'
|
27
|
+
KZ_IMPROVE_CUSTOM_YAML_PATH = KZ_POD_CONFIG_SUPPORT_FILES + 'kz_improve_custom_yaml.sh'
|
28
|
+
|
29
|
+
KZ_ON_DEMAND_RESOURCES = KZ_POD_CONFIG_SUPPORT_FILES + 'on_demand_resources'
|
30
|
+
KZ_ON_DEMAND_RESOURCES_SHELL = KZ_ON_DEMAND_RESOURCES + 'kz_on_demand_resources_xocde.sh'
|
27
31
|
|
28
32
|
def self.deal_path_for_xcconfig(path, add_quotes = false)
|
29
33
|
if path.is_a?(String)
|
@@ -51,6 +55,7 @@ module KZ
|
|
51
55
|
attr_accessor :generate_kz_pod_targets
|
52
56
|
attr_accessor :debug_shell_log_tag
|
53
57
|
attr_accessor :arm64_simulator
|
58
|
+
attr_accessor :on_demand_resources_bundle_id
|
54
59
|
|
55
60
|
private_class_method :new
|
56
61
|
|
@@ -88,11 +93,8 @@ module KZ
|
|
88
93
|
end
|
89
94
|
FileUtils.mkdir_p(KZ_POD_CONFIG_SUPPORT_FILES) unless File.exist?(KZ_POD_CONFIG_SUPPORT_FILES)
|
90
95
|
FileUtils.mkdir_p(KZ_POD_CONFIG_POD_TARGETS) unless File.exist?(KZ_POD_CONFIG_POD_TARGETS)
|
91
|
-
FileUtils.
|
92
|
-
|
93
|
-
FileUtils.rm(FLEX_COMPLIER_PATH) if File.exist?(FLEX_COMPLIER_PATH)
|
94
|
-
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler', FLEX_COMPLIER_PATH)
|
95
|
-
system("chmod +x #{FLEX_COMPLIER_PATH}")
|
96
|
+
FileUtils.rm_rf(KZ_POD_CONFIG_POD_TEMPDIR) if File.exist?(KZ_POD_CONFIG_POD_TEMPDIR)
|
97
|
+
FileUtils.mkdir_p(KZ_POD_CONFIG_POD_TEMPDIR)
|
96
98
|
|
97
99
|
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_generator_framework.sh', KZ_GENERATOR_FRAMEWORK_PATH)
|
98
100
|
system("chmod +x #{KZ_GENERATOR_FRAMEWORK_PATH}")
|
@@ -105,13 +107,34 @@ module KZ
|
|
105
107
|
|
106
108
|
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_refresh_pods_pbxproj.rb', KZ_FEFRESH_PODS_PBXPROJ)
|
107
109
|
|
110
|
+
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_improve_custom_yaml.sh', KZ_IMPROVE_CUSTOM_YAML_PATH)
|
111
|
+
system("chmod +x #{KZ_IMPROVE_CUSTOM_YAML_PATH}")
|
112
|
+
|
108
113
|
Pod::Config.instance.podfile.use_frameworks!(:linkage => :static)
|
114
|
+
|
115
|
+
if !@on_demand_resources_bundle_id.nil?
|
116
|
+
FileUtils.rm_r(KZ_ON_DEMAND_RESOURCES) if File.exist?(KZ_ON_DEMAND_RESOURCES)
|
117
|
+
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/on_demand_resources/', KZ_ON_DEMAND_RESOURCES)
|
118
|
+
system("chmod +x #{KZ_ON_DEMAND_RESOURCES_SHELL}")
|
119
|
+
end
|
109
120
|
else
|
110
121
|
@kz_pod_enable = false
|
111
122
|
@generate_kz_pod_targets = false
|
112
123
|
end
|
113
124
|
end
|
114
125
|
|
126
|
+
def handle_flexCompiler
|
127
|
+
if have_flexLib_pod_target
|
128
|
+
FileUtils.rm(FLEX_COMPLIER_PATH) if File.exist?(FLEX_COMPLIER_PATH)
|
129
|
+
if @kz_analyzer.pod_of_flexlib_info.flexLib_version.major >= 4
|
130
|
+
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler_V1', FLEX_COMPLIER_PATH)
|
131
|
+
else
|
132
|
+
FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler', FLEX_COMPLIER_PATH)
|
133
|
+
end
|
134
|
+
system("chmod +x #{FLEX_COMPLIER_PATH}")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
115
138
|
def analyze_special_parameters(use_code_tag, use_framework_tag, pod_names)
|
116
139
|
specify_pod_names = []
|
117
140
|
if pod_names.count > 0
|
@@ -144,10 +167,13 @@ module KZ
|
|
144
167
|
end
|
145
168
|
|
146
169
|
def have_flexLib_pod_target
|
170
|
+
return @kz_analyzer.pod_of_flexlib_info.have_kzswiftui_pod || @kz_analyzer.pod_of_flexlib_info.have_flexLib_pod
|
171
|
+
end
|
172
|
+
|
173
|
+
def check_and_copy_flex_compiler
|
147
174
|
@kz_analyzer.all_kz_pod_targets.values.each do |target|
|
148
175
|
return true if target.root_name == 'FlexLib' || target.root_name == 'KZSwiftUI'
|
149
176
|
end
|
150
|
-
false
|
151
177
|
end
|
152
178
|
|
153
179
|
def write_lock_file
|
@@ -26,6 +26,8 @@ module KZ
|
|
26
26
|
# 用于临时保存hamp过程的配置
|
27
27
|
attr_accessor :private_header_search_path
|
28
28
|
attr_accessor :repair_header_search_path
|
29
|
+
attr_accessor :custom_yaml_path
|
30
|
+
attr_accessor :custom_origin_yaml_path
|
29
31
|
|
30
32
|
attr_accessor :platform_name
|
31
33
|
# target编译最终的产物名称
|
@@ -67,6 +69,8 @@ module KZ
|
|
67
69
|
@force_load = false
|
68
70
|
@use_modulemap = true
|
69
71
|
@disable_to_simulator_frameworks = []
|
72
|
+
# 配置按需加载的资源,需要从bundle target中移除,然后手动进行配置
|
73
|
+
@on_demand_resources = []
|
70
74
|
|
71
75
|
native_pod_target.file_accessors.each do |file_accessor|
|
72
76
|
file_accessor.kz_pod_target = self
|
@@ -233,8 +237,8 @@ module KZ
|
|
233
237
|
# 获取target对应的配置根目录,部分文件需要依赖版本进行存储
|
234
238
|
def pod_config_cache_path(concat_version, vendored_framework = false)
|
235
239
|
kz_target_config_folder = KZ_POD_CONFIG_POD_TARGETS + @name
|
236
|
-
kz_target_config_folder += "vendored_framework" if vendored_framework
|
237
240
|
kz_target_config_folder += @version if concat_version
|
241
|
+
kz_target_config_folder += "vendored_framework" if vendored_framework
|
238
242
|
kz_target_config_folder
|
239
243
|
end
|
240
244
|
|
@@ -252,7 +256,7 @@ module KZ
|
|
252
256
|
end
|
253
257
|
end
|
254
258
|
end
|
255
|
-
|
259
|
+
@native_pod_target.product_module_name
|
256
260
|
end
|
257
261
|
|
258
262
|
# 获取所有用于修复的modulemap路径,原因参考@repair_modulemap_path
|
@@ -280,6 +284,10 @@ module KZ
|
|
280
284
|
@native_pod_target.prefix_header_path
|
281
285
|
end
|
282
286
|
|
287
|
+
def umbrella_header_path
|
288
|
+
@native_pod_target.umbrella_header_path
|
289
|
+
end
|
290
|
+
|
283
291
|
# 当前pod是否存在可编译的文件,配置framework后当前pod就不存在可编译文件
|
284
292
|
def current_should_build?
|
285
293
|
@native_pod_target.should_build?
|
@@ -333,5 +341,19 @@ module KZ
|
|
333
341
|
@native_pod_target.configuration_build_dir
|
334
342
|
end
|
335
343
|
|
344
|
+
def add_on_demand_resources(path)
|
345
|
+
@on_demand_resources.push(path).uniq!
|
346
|
+
end
|
347
|
+
def get_on_demand_resources
|
348
|
+
@on_demand_resources
|
349
|
+
end
|
350
|
+
|
351
|
+
def get_swift_lldb_ast_path
|
352
|
+
if current_should_build? and current_uses_swift?
|
353
|
+
return "$(TARGET_BUILD_DIR)/#{root_name}/#{product_name}/Modules/#{product_basename}.swiftmodule/$(NATIVE_ARCH_ACTUAL)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(SHALLOW_BUNDLE_TRIPLE).swiftmodule"
|
354
|
+
end
|
355
|
+
nil
|
356
|
+
end
|
357
|
+
|
336
358
|
end
|
337
359
|
end
|
@@ -40,6 +40,16 @@ module Pod
|
|
40
40
|
KZ::KZGlobalHelper.instance.kz_pod_config.merge!(kz_pod_config)
|
41
41
|
end
|
42
42
|
|
43
|
+
def kz_cocoapods_configure(*requirements)
|
44
|
+
configure = requirements.last
|
45
|
+
return false unless configure.is_a?(Hash)
|
46
|
+
|
47
|
+
on_demand_resources_bundle_id = configure.delete(:on_demand_resources_bundle_id)
|
48
|
+
if !on_demand_resources_bundle_id.nil? && on_demand_resources_bundle_id.is_a?(String)
|
49
|
+
KZ::KZGlobalHelper.instance.on_demand_resources_bundle_id = on_demand_resources_bundle_id
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
43
53
|
end
|
44
54
|
end
|
45
55
|
end
|
@@ -70,18 +70,38 @@ module Pod
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
alias_method :origin_vendored_libraries, :vendored_libraries
|
74
|
+
def vendored_libraries
|
75
|
+
if self.kz_pod_target and KZ::KZGlobalHelper.instance.arm64_simulator
|
76
|
+
return []
|
77
|
+
else
|
78
|
+
origin_vendored_libraries
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
73
82
|
alias_method :origin_vendored_frameworks, :vendored_frameworks
|
74
83
|
def vendored_frameworks
|
75
84
|
if self.kz_pod_target
|
76
|
-
|
77
|
-
if KZ::KZGlobalHelper.instance.arm64_simulator
|
78
|
-
|
85
|
+
new_frameworks = []
|
86
|
+
if KZ::KZGlobalHelper.instance.arm64_simulator
|
87
|
+
libraries = origin_vendored_libraries
|
88
|
+
if libraries.count > 0
|
89
|
+
new_frameworks.concat(KZ::KZFrameworkManager.handle_origin_library(libraries, self.kz_pod_target))
|
90
|
+
end
|
91
|
+
frameworks = origin_vendored_frameworks
|
92
|
+
if frameworks.count > 0
|
93
|
+
new_frameworks.concat(KZ::KZFrameworkManager.handle_origin_framework(frameworks, self.kz_pod_target))
|
94
|
+
end
|
95
|
+
else
|
96
|
+
new_frameworks.concat(origin_vendored_frameworks)
|
79
97
|
end
|
98
|
+
|
99
|
+
# 是否开启framework模式
|
80
100
|
result = KZ::KZGlobalHelper.instance.pod_config_result_with_target(self.kz_pod_target)
|
81
101
|
if !self.spec.test_specification && result
|
82
|
-
|
102
|
+
new_frameworks.concat(result.get_framework_paths)
|
83
103
|
end
|
84
|
-
|
104
|
+
new_frameworks
|
85
105
|
else
|
86
106
|
origin_vendored_frameworks
|
87
107
|
end
|
@@ -16,6 +16,7 @@ module Pod
|
|
16
16
|
kz_analyer.analyer
|
17
17
|
KZ::KZGlobalHelper.instance.kz_analyzer = kz_analyer
|
18
18
|
KZ::KZGlobalHelper.instance.kz_generator = KZ::KZGenerator.new(main_project)
|
19
|
+
KZ::KZGlobalHelper.instance.handle_flexCompiler
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
@@ -24,6 +25,9 @@ module Pod
|
|
24
25
|
if KZ::KZGlobalHelper.instance.kz_pod_enable
|
25
26
|
# hmap的创建需要在download之后,integrate之前
|
26
27
|
KZ::KZGlobalHelper.instance.kz_generator.create_hamp
|
28
|
+
unless KZ::KZGlobalHelper.instance.on_demand_resources_bundle_id.nil?
|
29
|
+
KZ::KZGlobalHelper.instance.kz_generator.create_on_demand_resources
|
30
|
+
end
|
27
31
|
end
|
28
32
|
original_integrate
|
29
33
|
end
|
@@ -27,6 +27,10 @@ module Pod
|
|
27
27
|
if kz_pod_target.force_load
|
28
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
29
|
end
|
30
|
+
|
31
|
+
unless kz_pod_target.custom_origin_yaml_path.nil?
|
32
|
+
KZ::KZGlobalHelper.instance.kz_generator.add_improve_yaml_build_phase(self.project, target_installation_result.native_target, kz_pod_target.custom_yaml_path)
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
if kz_pod_target && !kz_pod_target.use_modulemap
|
@@ -39,6 +43,25 @@ module Pod
|
|
39
43
|
target_installation_result
|
40
44
|
end
|
41
45
|
|
46
|
+
alias_method :origin_filter_resource_file_references, :filter_resource_file_references
|
47
|
+
def filter_resource_file_references(resource_file_references)
|
48
|
+
kz_pod_target = self.target.weakRef_kz_pod_target
|
49
|
+
if kz_pod_target
|
50
|
+
new_resource_file_references = []
|
51
|
+
odr_resources = kz_pod_target.get_on_demand_resources
|
52
|
+
resource_file_references.each do |path|
|
53
|
+
new_resource_file_references.push(path) unless odr_resources.include?(path)
|
54
|
+
end
|
55
|
+
origin_filter_resource_file_references(new_resource_file_references) do |compile_phase_refs, resources_phase_refs|
|
56
|
+
yield compile_phase_refs, resources_phase_refs
|
57
|
+
end
|
58
|
+
else
|
59
|
+
origin_filter_resource_file_references(resource_file_references) do |compile_phase_refs, resources_phase_refs|
|
60
|
+
yield compile_phase_refs, resources_phase_refs
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
42
65
|
end
|
43
66
|
end
|
44
67
|
end
|
@@ -21,6 +21,8 @@ module Pod
|
|
21
21
|
kz_clean_xcconfig(xcconfig)
|
22
22
|
main_hamp_search_path = '"' + KZ::KZ_POD_CONFIG_ROOT_STR + "/#{self.target.user_project.root_object.display_name}.hmap" + '"'
|
23
23
|
pod_targets = self.target.pod_targets_for_build_configuration(generator.configuration_name)
|
24
|
+
|
25
|
+
swift_lldb_ast_paths = []
|
24
26
|
pod_targets.each do |native_pod_target|
|
25
27
|
kz_pod_target = native_pod_target.weakRef_kz_pod_target
|
26
28
|
if kz_pod_target
|
@@ -33,8 +35,16 @@ module Pod
|
|
33
35
|
if kz_pod_target.force_load
|
34
36
|
kz_add_force_load_tag(xcconfig, kz_pod_target)
|
35
37
|
end
|
38
|
+
|
39
|
+
# 添加swift ast path
|
40
|
+
ast_path = kz_pod_target.get_swift_lldb_ast_path
|
41
|
+
if !ast_path.nil? and generator.configuration_name == "Debug"
|
42
|
+
swift_lldb_ast_paths << ast_path
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
46
|
+
|
47
|
+
kz_add_swift_lldb_ast_paths(xcconfig, swift_lldb_ast_paths)
|
38
48
|
xcconfig.attributes['HEADER_SEARCH_PATHS'] = main_hamp_search_path
|
39
49
|
xcconfig.attributes['USE_HEADERMAP'] = 'NO'
|
40
50
|
if KZ::KZGlobalHelper.instance.arm64_simulator
|
@@ -64,6 +74,38 @@ module Pod
|
|
64
74
|
xcconfig.attributes['VALID_ARCHS'] = 'arm64 arm64_32 x86_64'
|
65
75
|
end
|
66
76
|
|
77
|
+
unless kz_pod_target.custom_origin_yaml_path.nil?
|
78
|
+
xcconfig.attributes['KZ_CUSTOM_ORIGIN_YAML_PATH'] = kz_pod_target.custom_origin_yaml_path
|
79
|
+
xcconfig.attributes['KZ_CUSTOM_YAML_PATH'] = kz_pod_target.custom_yaml_path
|
80
|
+
|
81
|
+
other_cflags = xcconfig.attributes['OTHER_CFLAGS']
|
82
|
+
if other_cflags == nil
|
83
|
+
other_cflags = ""
|
84
|
+
elsif !other_cflags.end_with?(" ")
|
85
|
+
other_cflags += " "
|
86
|
+
end
|
87
|
+
other_cflags += ("-ivfsoverlay #{KZ.deal_path_for_xcconfig(kz_pod_target.custom_yaml_path, true)}")
|
88
|
+
xcconfig.attributes['OTHER_CFLAGS'] = other_cflags
|
89
|
+
|
90
|
+
other_cplusplusflags = xcconfig.attributes['OTHER_CPLUSPLUSFLAGS']
|
91
|
+
if other_cplusplusflags == nil
|
92
|
+
other_cplusplusflags = ""
|
93
|
+
elsif !other_cplusplusflags.end_with?(" ")
|
94
|
+
other_cplusplusflags += " "
|
95
|
+
end
|
96
|
+
other_cplusplusflags += ("-ivfsoverlay #{KZ.deal_path_for_xcconfig(kz_pod_target.custom_yaml_path, true)}")
|
97
|
+
xcconfig.attributes['OTHER_CPLUSPLUSFLAGS'] = other_cplusplusflags
|
98
|
+
|
99
|
+
other_swift_flags = xcconfig.attributes['OTHER_SWIFT_FLAGS']
|
100
|
+
if other_swift_flags == nil
|
101
|
+
other_swift_flags = ""
|
102
|
+
elsif !other_swift_flags.end_with?(" ")
|
103
|
+
other_swift_flags += " "
|
104
|
+
end
|
105
|
+
other_swift_flags += ("-Xcc -ivfsoverlay -Xcc #{KZ.deal_path_for_xcconfig(kz_pod_target.custom_yaml_path, true)}")
|
106
|
+
xcconfig.attributes['OTHER_SWIFT_FLAGS'] = other_swift_flags
|
107
|
+
end
|
108
|
+
|
67
109
|
add_repair_modulemap(xcconfig, kz_pod_target.all_repair_modulemap_paths, kz_pod_target.current_uses_swift?)
|
68
110
|
add_repair_swift_include_path(xcconfig, kz_pod_target.all_repair_swift_include_paths, kz_pod_target.current_uses_swift?)
|
69
111
|
kz_update_xcconfig_file(xcconfig, path)
|
@@ -143,6 +185,16 @@ module Pod
|
|
143
185
|
force_flags.add(KZ.deal_path_for_xcconfig(kz_pod_target.force_load_info, true))
|
144
186
|
end
|
145
187
|
|
188
|
+
def kz_add_swift_lldb_ast_paths(xcconfig, swift_lldb_ast_paths)
|
189
|
+
if swift_lldb_ast_paths.count > 0
|
190
|
+
other_linker_flags = xcconfig.other_linker_flags
|
191
|
+
simple = other_linker_flags[:simple]
|
192
|
+
swift_lldb_ast_paths.each do |swift_lldb_ast_path|
|
193
|
+
simple.add("-Wl,-add_ast_path,#{KZ.deal_path_for_xcconfig(swift_lldb_ast_path, true)}")
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
146
198
|
end
|
147
199
|
end
|
148
200
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
module Pod
|
3
|
+
class Installer
|
4
|
+
class UserProjectIntegrator
|
5
|
+
class TargetIntegrator
|
6
|
+
|
7
|
+
alias_method :origin_integrate!, :integrate!
|
8
|
+
def integrate!
|
9
|
+
origin_integrate!
|
10
|
+
|
11
|
+
unless KZ::KZGlobalHelper.instance.on_demand_resources_bundle_id.nil?
|
12
|
+
add_on_demand_resources_script_phase
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_on_demand_resources_script_phase
|
17
|
+
phase_name = "[KZ] On Demand Resources Build"
|
18
|
+
native_targets.each do |native_target|
|
19
|
+
if native_target.isa == "PBXNativeTarget" && native_target.product_type == "com.apple.product-type.application"
|
20
|
+
phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, phase_name)
|
21
|
+
native_target.build_phases.push(phase).uniq! unless native_target.build_phases.include?(phase)
|
22
|
+
phase.shell_script = KZ.deal_path_for_xcconfig(KZ::KZ_ON_DEMAND_RESOURCES_SHELL, true)
|
23
|
+
|
24
|
+
native_target.build_configurations.each do |config|
|
25
|
+
config.build_settings["ENABLE_ON_DEMAND_RESOURCES"] = "NO"
|
26
|
+
config.build_settings["KZ_POD_CONFIG_ROOT"] = KZ::KZ_POD_CONFIG_ROOT_STR
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/cocoapods-kz/native.rb
CHANGED
Binary file
|
Binary file
|
@@ -3,9 +3,13 @@ if [ "${MACH_O_TYPE}" != "staticlib" ]; then
|
|
3
3
|
fi
|
4
4
|
|
5
5
|
if [ -d "${KZ_FRAMEWORK_CACHE_PATH}" ]; then
|
6
|
-
|
6
|
+
if [ -d "${KZ_FRAMEWORK_CACHE_PATH}/${PRODUCT_NAME}.xcframework" ]; then
|
7
|
+
rm -r "${KZ_FRAMEWORK_CACHE_PATH}/${PRODUCT_NAME}.xcframework"
|
8
|
+
fi
|
9
|
+
else
|
10
|
+
mkdir -p "${KZ_FRAMEWORK_CACHE_PATH}"
|
7
11
|
fi
|
8
|
-
|
12
|
+
|
9
13
|
|
10
14
|
CURRENT_PRODUCT_DIR=${PODS_CONFIGURATION_BUILD_DIR}/${TARGET_NAME}
|
11
15
|
find "${CURRENT_PRODUCT_DIR}" -iname "*.bundle" | while read -r BUNDLE_FILE; do
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
set -e
|
3
|
+
set -u
|
4
|
+
set -o pipefail
|
5
|
+
|
6
|
+
function on_error {
|
7
|
+
echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
|
8
|
+
}
|
9
|
+
trap 'on_error $LINENO' ERR
|
10
|
+
|
11
|
+
if [ -z "${KZ_CUSTOM_ORIGIN_YAML_PATH+x}" ]; then
|
12
|
+
exit 0
|
13
|
+
fi
|
14
|
+
|
15
|
+
if [ -z "${KZ_CUSTOM_YAML_PATH+x}" ]; then
|
16
|
+
exit 0
|
17
|
+
fi
|
18
|
+
|
19
|
+
if [ ! -f "$KZ_CUSTOM_ORIGIN_YAML_PATH" ]; then
|
20
|
+
exit 0
|
21
|
+
fi
|
22
|
+
|
23
|
+
cp -f "$KZ_CUSTOM_ORIGIN_YAML_PATH" "$KZ_CUSTOM_YAML_PATH"
|
24
|
+
|
25
|
+
sed -i.bak "s|__built_products_dir__|${BUILT_PRODUCTS_DIR}|g" "$KZ_CUSTOM_YAML_PATH" && rm "$KZ_CUSTOM_YAML_PATH.bak"
|
@@ -4,14 +4,16 @@ require 'pathname'
|
|
4
4
|
current_pods_pbxproj_path = Pathname.new(ARGV[0])
|
5
5
|
temp_pods_pbxproj_path = Pathname.new(ARGV[1])
|
6
6
|
|
7
|
-
if
|
8
|
-
FileUtils.
|
9
|
-
|
7
|
+
if File.exist?(temp_pods_pbxproj_path)
|
8
|
+
if !File.exist?(current_pods_pbxproj_path) || !FileUtils.compare_file(current_pods_pbxproj_path, temp_pods_pbxproj_path)
|
9
|
+
FileUtils.cp_r(temp_pods_pbxproj_path, current_pods_pbxproj_path)
|
10
|
+
end
|
10
11
|
|
11
|
-
FileUtils.rm_r(Pathname(temp_pods_pbxproj_path).dirname)
|
12
|
+
FileUtils.rm_r(Pathname(temp_pods_pbxproj_path).dirname)
|
12
13
|
|
13
|
-
xcode_running = system("ps aux | grep '[X]code' > /dev/null 2>&1")
|
14
|
-
if xcode_running
|
15
|
-
|
14
|
+
xcode_running = system("ps aux | grep '[X]code' > /dev/null 2>&1")
|
15
|
+
if xcode_running
|
16
|
+
system("touch #{current_pods_pbxproj_path}")
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
data/lib/cocoapods-kz/resources/on_demand_resources/kz_complete_asset_pack_output_spec_plist.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
autoload :Nanaimo, 'nanaimo'
|
3
|
+
|
4
|
+
def write_to_path(hash, path)
|
5
|
+
unless path.is_a?(String) || path.is_a?(Pathname)
|
6
|
+
raise TypeError, "The given `#{path}` must be a string or 'pathname'."
|
7
|
+
end
|
8
|
+
path = path.to_s
|
9
|
+
raise IOError, 'Empty path.' if path.empty?
|
10
|
+
|
11
|
+
File.open(path, 'w') do |f|
|
12
|
+
plist = Nanaimo::Plist.new(hash, :xml)
|
13
|
+
Nanaimo::Writer::XMLWriter.new(plist, :pretty => true, :output => f, :strict => false).write
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
on_demand_resources_folder = ARGV[0]
|
18
|
+
asset_pack_output_specifications_plist_path = ARGV[1]
|
19
|
+
asset_pack_output_specifications_plist = Xcodeproj::Plist.read_from_path(asset_pack_output_specifications_plist_path)
|
20
|
+
asset_pack_output_specifications_plist.each do |item|
|
21
|
+
bundle_paht = item["bundle-path"]
|
22
|
+
unless bundle_paht.start_with?(on_demand_resources_folder)
|
23
|
+
item["bundle-path"] = "#{on_demand_resources_folder}/#{bundle_paht}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
write_to_path(asset_pack_output_specifications_plist, asset_pack_output_specifications_plist_path)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
require "date"
|
3
|
+
|
4
|
+
on_demand_resources_path = ARGV[0]
|
5
|
+
manifest_template_plist_path = ARGV[1]
|
6
|
+
manifest_url = "http://127.0.0.1"
|
7
|
+
|
8
|
+
manifest_template_plist_hash = {}
|
9
|
+
manifest_template_resources = []
|
10
|
+
manifest_template_plist_hash["resources"] = manifest_template_resources
|
11
|
+
|
12
|
+
Dir.foreach(on_demand_resources_path) do |sub_file|
|
13
|
+
if sub_file != "." && sub_file != ".." && sub_file != ".DS_Store"
|
14
|
+
resources_item = {}
|
15
|
+
primary_content_hash = {}
|
16
|
+
time = Time.now
|
17
|
+
primary_content_hash["hash"] = time.utc.strftime('%Y-%m-%dT%H:%M:%S.000Z')
|
18
|
+
primary_content_hash["strategy"] = "modtime"
|
19
|
+
resources_item["primaryContentHash"] = primary_content_hash
|
20
|
+
resources_item["isStreamable"] = true
|
21
|
+
total_size = 0
|
22
|
+
Dir.foreach("#{on_demand_resources_path}/#{sub_file}") do |resource|
|
23
|
+
if resource != "." && resource != ".." && resource != ".DS_Store"
|
24
|
+
if resource == "Info.plist"
|
25
|
+
info_plist = Xcodeproj::Plist.read_from_path("#{on_demand_resources_path}/#{sub_file}/#{resource}")
|
26
|
+
priority = info_plist["Priority"]
|
27
|
+
if priority && priority > 0
|
28
|
+
resources_item["downloadPriority"] = priority
|
29
|
+
end
|
30
|
+
resources_item["bundleKey"] = info_plist["CFBundleIdentifier"]
|
31
|
+
else
|
32
|
+
resources_item["URL"] = "#{manifest_url}#{on_demand_resources_path}/#{sub_file}"
|
33
|
+
total_size = total_size + File.size("#{on_demand_resources_path}/#{sub_file}/#{resource}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
resources_item["uncompressedSize"] = total_size
|
38
|
+
manifest_template_resources << resources_item
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
if manifest_template_resources.size > 0
|
43
|
+
Xcodeproj::Plist.write_to_path(manifest_template_plist_hash, manifest_template_plist_path)
|
44
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
|
3
|
+
kz_on_demand_resources_path = ARGV[0]
|
4
|
+
on_demand_resources_plist_path = ARGV[1]
|
5
|
+
|
6
|
+
on_demand_resources_plist = {}
|
7
|
+
bundle_resource_request_tags = {}
|
8
|
+
on_demand_resources_plist["NSBundleResourceRequestTags"] = bundle_resource_request_tags
|
9
|
+
bundle_resource_request_asset_packs = {}
|
10
|
+
on_demand_resources_plist["NSBundleResourceRequestAssetPacks"] = bundle_resource_request_asset_packs
|
11
|
+
|
12
|
+
Dir.foreach(kz_on_demand_resources_path) do |sub_file|
|
13
|
+
if sub_file != "." && sub_file != ".." && sub_file != ".DS_Store"
|
14
|
+
Dir.foreach("#{kz_on_demand_resources_path}/#{sub_file}") do |plist|
|
15
|
+
if plist == "OnDemandResources.plist"
|
16
|
+
info_plist = Xcodeproj::Plist.read_from_path("#{kz_on_demand_resources_path}/#{sub_file}/#{plist}")
|
17
|
+
bundle_resource_request_tags.update(info_plist["NSBundleResourceRequestTags"])
|
18
|
+
bundle_resource_request_asset_packs.update(info_plist["NSBundleResourceRequestAssetPacks"])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if bundle_resource_request_tags.size > 0 || bundle_resource_request_asset_packs.size > 0
|
25
|
+
Xcodeproj::Plist.write_to_path(on_demand_resources_plist, on_demand_resources_plist_path)
|
26
|
+
end
|