Class: KZ::KZPodTarget
- Inherits:
-
Object
- Object
- KZ::KZPodTarget
- Defined in:
- lib/cocoapods-kz/helpers/kz_pod_target.rb
Instance Attribute Summary collapse
-
#config_pod_mode ⇒ Object
重些config_pod_mode的get方法,force_config_pod_mode优先级最高.
-
#custom_origin_yaml_path ⇒ Object
Returns the value of attribute custom_origin_yaml_path.
-
#custom_yaml_path ⇒ Object
Returns the value of attribute custom_yaml_path.
-
#dependent_target_info ⇒ Object
当前target所有直接或间接依赖的target信息,是一个hash,key为target名字,value为KZPodTarget对象.
-
#disable_to_simulator_frameworks ⇒ Object
Returns the value of attribute disable_to_simulator_frameworks.
-
#force_config_pod_mode ⇒ Object
pod kz install/update 中指定的pod模式,优先级最大.
-
#force_load ⇒ Object
Returns the value of attribute force_load.
-
#force_load_info ⇒ Object
Returns the value of attribute force_load_info.
-
#have_same_root ⇒ Object
是否存在跟其他pod相同的root pod,一搬为同一个pod,再不同target中拆分为sub pod使用.
-
#is_dev_pod ⇒ Object
Returns the value of attribute is_dev_pod.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#native_pod_target ⇒ Object
readonly
Returns the value of attribute native_pod_target.
-
#need_repair_module_import ⇒ Object
当手动修改PRODUCT_NAME之后,#import<xx/xxx.h>需要修复为原使用方式,使用hmap进行映射.
-
#on_demand_resources_config_path ⇒ Object
Returns the value of attribute on_demand_resources_config_path.
-
#on_demand_resources_config_patterns ⇒ Object
Returns the value of attribute on_demand_resources_config_patterns.
-
#origin_product_name ⇒ Object
target原始产物名称.
-
#platform_name ⇒ Object
Returns the value of attribute platform_name.
-
#private_header_search_path ⇒ Object
用于临时保存hamp过程的配置.
-
#product_basename ⇒ Object
对应xcode配置PRODUCT_NAME,当多个target的PRODUCT_NAME相同时,需要手动修改,防止打包报错.
-
#product_name ⇒ Object
target编译最终的产物名称.
-
#repair_dependent_target_info ⇒ Object
所有通过kz_pod,:dependency手动配置的依赖target.
-
#repair_header_search_path ⇒ Object
Returns the value of attribute repair_header_search_path.
-
#repair_import ⇒ Object
readonly
Returns the value of attribute repair_import.
-
#repair_modulemap_path ⇒ Object
当手动修改PRODUCT_NAME之后,产物名称会改变,在framework模式下对于OC组件需要使用modulemap文件配置寻找路径,对于Swift组件需要配置单独的include path.
-
#repair_swift_include_path ⇒ Object
Returns the value of attribute repair_swift_include_path.
-
#root_name ⇒ Object
readonly
部分pod配置了subspec,此时获取的name为cocoapods处理之后的名字,可以通过root_name拿到pod本名.
-
#use_local_private_headers_path ⇒ Object
Returns the value of attribute use_local_private_headers_path.
-
#use_modulemap ⇒ Object
Returns the value of attribute use_modulemap.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#add_kz_pod_config(pod_config) ⇒ Object
配合kz_pod对target进行配置.
- #all_headers ⇒ Object
-
#all_need_repair_import ⇒ Object
在当前target的所有依赖中,过滤有有修补的target.
-
#all_repair_dependent_target_info ⇒ Object
参考@repair_dependent_target_info,获取所有当前target直接或间接配置的依赖target 用于配置FRAMEWORK_SEARCH_PATHS内容.
-
#all_repair_header_search_paths ⇒ Object
获取当前target所有需要修补target的hmap.
-
#all_repair_modulemap_paths ⇒ Object
获取所有用于修复的modulemap路径,原因参考@repair_modulemap_path.
- #all_repair_swift_include_paths ⇒ Object
- #all_xcassets_paths ⇒ Object
- #configuration_build_dir(for_froce_load = false) ⇒ Object
-
#current_should_build? ⇒ Boolean
当前pod是否存在可编译的文件,配置framework后当前pod就不存在可编译文件.
- #current_uses_swift? ⇒ Boolean
- #get_swift_lldb_ast_path ⇒ Object
-
#header_search_paths(custom_paths) ⇒ Object
直接用于配置HEADER_SEARCH_PATHS.
-
#initialize(native_pod_target) ⇒ KZPodTarget
constructor
A new instance of KZPodTarget.
-
#kz_module_name ⇒ Object
获取target中的module name,默认为product_module_name与target.name也相同。 部分target导入的framework名字与modulemap中的名字不对应,需要特殊处理 eg.AMapSearch,product_module_name为AMapSearch,modulemap中的名字为AMapSearchKit.
- #local_private_headers_path ⇒ Object
- #on_demand_resources_info ⇒ Object
-
#origin_should_build? ⇒ Boolean
原pod是否存在可编译的文件.
- #origin_uses_swift? ⇒ Boolean
-
#pod_config_cache_path(concat_version, vendored_framework = false, on_demand_resources = false) ⇒ Object
获取target对应的配置根目录,部分文件需要依赖版本进行存储.
- #prefix_header_path ⇒ Object
- #public_headers ⇒ Object
-
#recursive_dependent_targets ⇒ Object
获取当前target所有依赖,包括手动补充的.
- #traversal_resource_for_tag(plist_hash, path_list) ⇒ Object
- #umbrella_header_path ⇒ Object
- #uses_swift ⇒ Object
- #uses_swift_for_spec?(spec) ⇒ Boolean
Constructor Details
#initialize(native_pod_target) ⇒ KZPodTarget
Returns a new instance of KZPodTarget.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 64 def initialize(native_pod_target) @native_pod_target = native_pod_target @name = native_pod_target.name @root_name = native_pod_target.root_spec.name @version = native_pod_target.version @dependent_target_info = {} @repair_dependent_target_info = {} @repair_import = [] @is_dev_pod = false @config_pod_mode = :kz_pod_origin_mode @platform_name = native_pod_target.platform.symbolic_name @have_same_root = false @product_name = native_pod_target.origin_product_name @origin_product_name = native_pod_target.origin_product_name @product_basename = native_pod_target.origin_product_basename @need_repair_module_import = false @use_local_private_headers_path = false @force_load = false @use_modulemap = true @disable_to_simulator_frameworks = [] # 配置按需加载的资源,需要从bundle target中移除,然后手动进行配置 @on_demand_resources = [] native_pod_target.file_accessors.each do |file_accessor| file_accessor.kz_pod_target = self end native_pod_target.weakRef_kz_pod_target = WeakRef.new(self) end |
Instance Attribute Details
#config_pod_mode ⇒ Object
重些config_pod_mode的get方法,force_config_pod_mode优先级最高
26 27 28 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 26 def config_pod_mode @config_pod_mode end |
#custom_origin_yaml_path ⇒ Object
Returns the value of attribute custom_origin_yaml_path.
34 35 36 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 34 def custom_origin_yaml_path @custom_origin_yaml_path end |
#custom_yaml_path ⇒ Object
Returns the value of attribute custom_yaml_path.
33 34 35 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 33 def custom_yaml_path @custom_yaml_path end |
#dependent_target_info ⇒ Object
当前target所有直接或间接依赖的target信息,是一个hash,key为target名字,value为KZPodTarget对象
20 21 22 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 20 def dependent_target_info @dependent_target_info end |
#disable_to_simulator_frameworks ⇒ Object
Returns the value of attribute disable_to_simulator_frameworks.
59 60 61 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 59 def disable_to_simulator_frameworks @disable_to_simulator_frameworks end |
#force_config_pod_mode ⇒ Object
pod kz install/update 中指定的pod模式,优先级最大
28 29 30 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 28 def force_config_pod_mode @force_config_pod_mode end |
#force_load ⇒ Object
Returns the value of attribute force_load.
54 55 56 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 54 def force_load @force_load end |
#force_load_info ⇒ Object
Returns the value of attribute force_load_info.
55 56 57 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 55 def force_load_info @force_load_info end |
#have_same_root ⇒ Object
是否存在跟其他pod相同的root pod,一搬为同一个pod,再不同target中拆分为sub pod使用
38 39 40 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 38 def have_same_root @have_same_root end |
#is_dev_pod ⇒ Object
Returns the value of attribute is_dev_pod.
24 25 26 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 24 def is_dev_pod @is_dev_pod end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 15 def name @name end |
#native_pod_target ⇒ Object (readonly)
Returns the value of attribute native_pod_target.
14 15 16 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 14 def native_pod_target @native_pod_target end |
#need_repair_module_import ⇒ Object
当手动修改PRODUCT_NAME之后,#import<xx/xxx.h>需要修复为原使用方式,使用hmap进行映射
50 51 52 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 50 def need_repair_module_import @need_repair_module_import end |
#on_demand_resources_config_path ⇒ Object
Returns the value of attribute on_demand_resources_config_path.
62 63 64 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 62 def on_demand_resources_config_path @on_demand_resources_config_path end |
#on_demand_resources_config_patterns ⇒ Object
Returns the value of attribute on_demand_resources_config_patterns.
61 62 63 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 61 def on_demand_resources_config_patterns @on_demand_resources_config_patterns end |
#origin_product_name ⇒ Object
target原始产物名称
42 43 44 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 42 def origin_product_name @origin_product_name end |
#platform_name ⇒ Object
Returns the value of attribute platform_name.
36 37 38 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 36 def platform_name @platform_name end |
#private_header_search_path ⇒ Object
用于临时保存hamp过程的配置
31 32 33 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 31 def private_header_search_path @private_header_search_path end |
#product_basename ⇒ Object
对应xcode配置PRODUCT_NAME,当多个target的PRODUCT_NAME相同时,需要手动修改,防止打包报错
44 45 46 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 44 def product_basename @product_basename end |
#product_name ⇒ Object
target编译最终的产物名称
40 41 42 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 40 def product_name @product_name end |
#repair_dependent_target_info ⇒ Object
所有通过kz_pod,:dependency手动配置的依赖target
22 23 24 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 22 def repair_dependent_target_info @repair_dependent_target_info end |
#repair_header_search_path ⇒ Object
Returns the value of attribute repair_header_search_path.
32 33 34 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 32 def repair_header_search_path @repair_header_search_path end |
#repair_import ⇒ Object (readonly)
Returns the value of attribute repair_import.
23 24 25 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 23 def repair_import @repair_import end |
#repair_modulemap_path ⇒ Object
当手动修改PRODUCT_NAME之后,产物名称会改变,在framework模式下对于OC组件需要使用modulemap文件配置寻找路径,对于Swift组件需要配置单独的include path
46 47 48 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 46 def repair_modulemap_path @repair_modulemap_path end |
#repair_swift_include_path ⇒ Object
Returns the value of attribute repair_swift_include_path.
47 48 49 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 47 def repair_swift_include_path @repair_swift_include_path end |
#root_name ⇒ Object (readonly)
部分pod配置了subspec,此时获取的name为cocoapods处理之后的名字,可以通过root_name拿到pod本名
17 18 19 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 17 def root_name @root_name end |
#use_local_private_headers_path ⇒ Object
Returns the value of attribute use_local_private_headers_path.
52 53 54 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 52 def use_local_private_headers_path @use_local_private_headers_path end |
#use_modulemap ⇒ Object
Returns the value of attribute use_modulemap.
57 58 59 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 57 def use_modulemap @use_modulemap end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
18 19 20 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 18 def version @version end |
Instance Method Details
#add_kz_pod_config(pod_config) ⇒ Object
配合kz_pod对target进行配置
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 131 def add_kz_pod_config(pod_config) return unless pod_config repair_dependency = pod_config[:dependency] if repair_dependency repair_dependency.each { |repair_dependent_pod_target_name| kz_repair_pod_target = yield(repair_dependent_pod_target_name) if kz_repair_pod_target native_dependent_targets_by_config = self.native_pod_target.dependent_targets_by_config native_dependent_targets_by_config.each do |_, dependent_targets| dependent_targets << kz_repair_pod_target.native_pod_target end self.native_pod_target.dependent_targets_by_config = native_dependent_targets_by_config @dependent_target_info[repair_dependent_pod_target_name] = kz_repair_pod_target @repair_dependent_target_info[repair_dependent_pod_target_name] = kz_repair_pod_target end } end repair_import = pod_config[:repair_import] if repair_import.is_a?(TrueClass) @repair_import = self.recursive_dependent_targets elsif repair_import.is_a?(Array) repair_import.each do |repair_import_target_name| kz_repair_pod_target = yield(repair_import_target_name) @repair_import << kz_repair_pod_target if kz_repair_pod_target end end force_load = pod_config[:force_load] if force_load.is_a?(TrueClass) @force_load = true end use_modulemap = pod_config[:use_modulemap] if use_modulemap.is_a?(FalseClass) @use_modulemap = false end end |
#all_headers ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 99 def all_headers @all_headers ||= begin all_headers = [] native_pod_target.file_accessors.each do |file_accessor| next if file_accessor.spec.test_specification all_headers.concat(file_accessor.kz_headers) end all_headers end end |
#all_need_repair_import ⇒ Object
在当前target的所有依赖中,过滤有有修补的target
174 175 176 177 178 179 180 181 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 174 def all_need_repair_import all_need_repair_import = [] self.recursive_dependent_targets.each do |dependent_target| all_need_repair_import << dependent_target if dependent_target.repair_import.count > 0 end all_need_repair_import.uniq end |
#all_repair_dependent_target_info ⇒ Object
参考@repair_dependent_target_info,获取所有当前target直接或间接配置的依赖target 用于配置FRAMEWORK_SEARCH_PATHS内容
229 230 231 232 233 234 235 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 229 def all_repair_dependent_target_info all_repair_dependent_target_info = @repair_dependent_target_info @dependent_target_info.values.each do |dependent_target| all_repair_dependent_target_info.merge!(dependent_target.all_repair_dependent_target_info) end all_repair_dependent_target_info end |
#all_repair_header_search_paths ⇒ Object
获取当前target所有需要修补target的hmap
217 218 219 220 221 222 223 224 225 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 217 def all_repair_header_search_paths all_repair_header_search_paths = [] all_repair_header_search_paths << KZ.deal_path_for_xcconfig(@repair_header_search_path, true) if @repair_header_search_path self.all_need_repair_import.each do |need_repair_target| sub_repair_header_search_path = need_repair_target.repair_header_search_path all_repair_header_search_paths << KZ.deal_path_for_xcconfig(sub_repair_header_search_path, true) if sub_repair_header_search_path end all_repair_header_search_paths.uniq end |
#all_repair_modulemap_paths ⇒ Object
获取所有用于修复的modulemap路径,原因参考@repair_modulemap_path
264 265 266 267 268 269 270 271 272 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 264 def all_repair_modulemap_paths all_repair_modulemap_paths = [] all_repair_modulemap_paths << repair_modulemap_path if self.repair_modulemap_path recursive_dependent_targets.each do |recursive_dependent_target| all_repair_modulemap_paths.concat(recursive_dependent_target.all_repair_modulemap_paths) end all_repair_modulemap_paths.uniq! if all_repair_modulemap_paths.count > 0 all_repair_modulemap_paths end |
#all_repair_swift_include_paths ⇒ Object
274 275 276 277 278 279 280 281 282 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 274 def all_repair_swift_include_paths all_repair_swift_include_paths = [] all_repair_swift_include_paths << repair_swift_include_path if self.repair_swift_include_path recursive_dependent_targets.each do |recursive_dependent_target| all_repair_swift_include_paths.concat(recursive_dependent_target.all_repair_swift_include_paths) end all_repair_swift_include_paths.uniq! if all_repair_swift_include_paths.count > 0 all_repair_swift_include_paths end |
#all_xcassets_paths ⇒ Object
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 403 def all_xcassets_paths @all_xcassets_paths ||= begin all_xcassets_paths = [] native_pod_target.file_accessors.each do |file_accessor| file_accessor.resource_bundles.map do |_, paths| paths.each do |path| if path.extname == ".xcassets" all_xcassets_paths << path end end end end all_xcassets_paths end end |
#configuration_build_dir(for_froce_load = false) ⇒ Object
338 339 340 341 342 343 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 338 def configuration_build_dir(for_froce_load = false) if for_froce_load return @native_pod_target.configuration_build_dir + "/.force_load" end @native_pod_target.configuration_build_dir end |
#current_should_build? ⇒ Boolean
当前pod是否存在可编译的文件,配置framework后当前pod就不存在可编译文件
293 294 295 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 293 def current_should_build? @native_pod_target.should_build? end |
#current_uses_swift? ⇒ Boolean
308 309 310 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 308 def current_uses_swift? @native_pod_target.uses_swift? end |
#get_swift_lldb_ast_path ⇒ Object
419 420 421 422 423 424 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 419 def get_swift_lldb_ast_path if current_should_build? and current_uses_swift? return "$(TARGET_BUILD_DIR)/#{root_name}/#{product_name}/Modules/#{product_basename}.swiftmodule/$(NATIVE_ARCH_ACTUAL)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(SHALLOW_BUNDLE_TRIPLE).swiftmodule" end nil end |
#header_search_paths(custom_paths) ⇒ Object
直接用于配置HEADER_SEARCH_PATHS
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 197 def header_search_paths(custom_paths) return '' unless current_should_build? header_search_paths = '' header_search_paths = KZ.deal_path_for_xcconfig(@private_header_search_path, true) if @private_header_search_path repair_header_search_paths = self.all_repair_header_search_paths.join(' ') if repair_header_search_paths.length > 0 header_search_paths += (' ' + repair_header_search_paths) end if @use_local_private_headers_path header_search_paths += (' ' + KZ.deal_path_for_xcconfig(local_private_headers_path, true)) end header_search_paths += (' ' + KZ.deal_path_for_xcconfig("${PODS_ROOT}/Headers/Public", true)) custom_paths.each do |custom_path| header_search_paths += (' ' + custom_path) end if custom_paths header_search_paths end |
#kz_module_name ⇒ Object
获取target中的module name,默认为product_module_name与target.name也相同。部分target导入的framework名字与modulemap中的名字不对应,需要特殊处理eg.AMapSearch,product_module_name为AMapSearch,modulemap中的名字为AMapSearchKit
249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 249 def kz_module_name return @native_pod_target.product_module_name unless all_headers.count > 0 one_header_path = all_headers.first.to_s if one_header_path.include?('.framework') one_header_path.split('/').each do |name| if name.include?('.framework') return name.split('.').first end end end @native_pod_target.product_module_name end |
#local_private_headers_path ⇒ Object
330 331 332 333 334 335 336 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 330 def local_private_headers_path @local_private_headers_path ||= begin path = KZ_POD_CONFIG_POD_TARGETS + @name + "Headers" FileUtils.mkdir_p(path) unless File.exist?(path) path end end |
#on_demand_resources_info ⇒ Object
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 345 def on_demand_resources_info return {} if @on_demand_resources_config_patterns.nil? pod_root = self.native_pod_target.sandbox.pod_dir(self.root_name) path_list = Pod::Sandbox::PathList.new(pod_root) list = path_list.glob(@on_demand_resources_config_patterns) result = list.select {|path| path.extname == ".plist" } on_demand_resources_info = {} result.each do |config_plist_path| begin plist_hash = Xcodeproj::Plist.read_from_path(config_plist_path) rescue => e KZLog.log("'#{@name}'中ODR配置文件:'#{config_plist_path}'格式不正确,请参考文档使用正确的plist文件", :error) next end initial_plist_hash = plist_hash[Initial_Install_Tags] traversal_resource_for_tag(initial_plist_hash, path_list) do |tag_resources| on_demand_resources_info[Initial_Install_Tags] = tag_resources end prefetched_plist_hash = plist_hash[Prefetched_Tag_Order] traversal_resource_for_tag(prefetched_plist_hash, path_list) do |tag_resources| on_demand_resources_info[Prefetched_Tag_Order] = tag_resources end download_plist_hash = plist_hash[Download_Only_On_Demand] traversal_resource_for_tag(download_plist_hash, path_list) do |tag_resources| on_demand_resources_info[Download_Only_On_Demand] = tag_resources end end on_demand_resources_info end |
#origin_should_build? ⇒ Boolean
原pod是否存在可编译的文件
298 299 300 301 302 303 304 305 306 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 298 def origin_should_build? return @origin_should_build if defined? @origin_should_build accessors = @native_pod_target.file_accessors.select { |fa| fa.spec.library_specification? } all_origin_compile_files = [] accessors.each do |accessor| all_origin_compile_files.concat(accessor.origin_source_files - accessor.kz_headers) end @origin_should_build = !all_origin_compile_files.empty? end |
#origin_uses_swift? ⇒ Boolean
312 313 314 315 316 317 318 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 312 def origin_uses_swift? return @uses_swift if defined? @uses_swift @uses_swift = (!origin_should_build? && !@native_pod_target.spec_swift_versions.empty?) || @native_pod_target.file_accessors.select { |a| a.spec.library_specification? }.any? do |file_accessor| uses_swift_for_spec?(file_accessor.spec) end end |
#pod_config_cache_path(concat_version, vendored_framework = false, on_demand_resources = false) ⇒ Object
获取target对应的配置根目录,部分文件需要依赖版本进行存储
238 239 240 241 242 243 244 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 238 def pod_config_cache_path(concat_version, vendored_framework = false, on_demand_resources = false) kz_target_config_folder = KZ_POD_CONFIG_POD_TARGETS + @name kz_target_config_folder += @version if concat_version kz_target_config_folder += "vendored_framework" if vendored_framework kz_target_config_folder += "on_demand_resources" if on_demand_resources kz_target_config_folder end |
#prefix_header_path ⇒ Object
284 285 286 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 284 def prefix_header_path @native_pod_target.prefix_header_path end |
#public_headers ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 111 def public_headers @public_headers ||= begin public_headers = [] native_pod_target.file_accessors.each do |file_accessor| next if file_accessor.spec.test_specification public_headers.concat(file_accessor.kz_public_headers) end public_headers end end |
#recursive_dependent_targets ⇒ Object
获取当前target所有依赖,包括手动补充的
184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 184 def recursive_dependent_targets recursive_dependent_targets = [] @dependent_target_info.values.each do |dependent_target| recursive_dependent_targets << dependent_target recursive_dependent_targets.concat(dependent_target.recursive_dependent_targets) end if recursive_dependent_targets.count > 0 recursive_dependent_targets.uniq end recursive_dependent_targets end |
#traversal_resource_for_tag(plist_hash, path_list) ⇒ Object
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 380 def traversal_resource_for_tag(plist_hash, path_list) if !plist_hash.nil? && plist_hash.size > 0 tag_resources = {} plist_hash.each do |tag, resource_paths| valid_paths = [] resource_paths.each do |resource_path| valid_path = path_list.relative_path_in_snadbox?(resource_path) unless valid_path.nil? valid_paths.append(valid_path) else KZLog.log("'#{@name}'中ODR资源路径:'#{resource_path}'不存在,请示使用相对podspec文件的相对路径", :warning) end end if valid_paths.size > 0 tag_resources[tag] = valid_paths end end yield(tag_resources) end end |
#umbrella_header_path ⇒ Object
288 289 290 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 288 def umbrella_header_path @native_pod_target.umbrella_header_path end |
#uses_swift ⇒ Object
95 96 97 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 95 def uses_swift native_pod_target.uses_swift? end |
#uses_swift_for_spec?(spec) ⇒ Boolean
320 321 322 323 324 325 326 327 328 |
# File 'lib/cocoapods-kz/helpers/kz_pod_target.rb', line 320 def uses_swift_for_spec?(spec) @uses_swift_for_spec_cache ||= {} return @uses_swift_for_spec_cache[spec.name] if @uses_swift_for_spec_cache.key?(spec.name) @uses_swift_for_spec_cache[spec.name] = begin file_accessor = @native_pod_target.file_accessors.find { |fa| fa.spec == spec } raise "[Bug] Unable to find file accessor for spec `#{spec.inspect}` in pod target `#{label}`" unless file_accessor file_accessor.origin_source_files.any? { |sf| sf.extname == '.swift' } end end |