class Pod::Installer::Xcode::PodsProjectGenerator::FileReferencesInstaller
Public Instance Methods
add_files(namespace, relative_header_paths,pod_module_name)
click to toggle source
# File lib/cocoapods-hmap/hmapcreate/hmap.rb, line 54 def add_files(namespace, relative_header_paths,pod_module_name) #要生成两个json 一个是给双引号的时候使用,一个是给<>的的使用 #双引号的Key只有 "ClassA.h"这种类型 #<>的key即有 “PodA/ClassA.h” 这种类型 也有"ClassA.h"这种类型 作为生成大的public时使用 hmap_own_content = "" hmap_public_content = "" relative_header_paths.map do |relative_header_path| #own hmap的生成 只包含 ClassA这种类型 item = generate_own_hmap_item(namespace,relative_header_path) hmap_own_content = hmap_own_content + "#{item},\n" #public json生成 包含PodA/ClassA ClassA两种类型 public_item = generate_public_hmap_item(namespace,relative_header_path,pod_module_name) hmap_public_content = hmap_public_content + "#{public_item},\n" end hmap_own_content = hmap_own_content.chomp.chop hmap_public_content = hmap_public_content.chomp.chop results = [] results.append(hmap_own_content) results.append(hmap_public_content) return results # return hmap_content end
generate_own_hmap_file(namespace,hmap_content)
click to toggle source
# File lib/cocoapods-hmap/hmapcreate/hmap.rb, line 132 def generate_own_hmap_file(namespace,hmap_content) hmap_path = File.join(sandbox.headers_root,"headermap/#{namespace}") `rm -rf #{hmap_path}` if Dir.exist?(hmap_path) `mkdir -p #{hmap_path}` hmap_json_file = File.join(hmap_path,"#{namespace}.json") File.open(hmap_json_file, 'w'){|file| file.write(hmap_content)} #创建hmap hmap_file = File.join(hmap_path,"#{namespace}.hmap") `hmap convert #{hmap_json_file} #{hmap_file}` # `rm -rf #{hmap_json_file}` end
generate_own_hmap_item(namespace,relative_header_path)
click to toggle source
# File lib/cocoapods-hmap/hmapcreate/hmap.rb, line 78 def generate_own_hmap_item(namespace,relative_header_path) header_name = relative_header_path.basename hmap_module_key = header_name.to_s suffix = relative_header_path.basename.to_s #prefix的计算 absolute_source = (@sandbox.root + relative_header_path) prefix = File.join(absolute_source.dirname,'/') value_item = Hash.new() value_item["prefix"] = prefix value_item["suffix"] = suffix hmap_module_item = Hash.new() hmap_module_item[hmap_module_key] = value_item require 'json' hmap_module_string = hmap_module_item.to_json hmap_module_string = hmap_module_string.chop.reverse.chop.reverse return hmap_module_string end
generate_pch_hmap_item(namespace)
click to toggle source
# File lib/cocoapods-hmap/hmapcreate/hmap.rb, line 150 def generate_pch_hmap_item(namespace) suffix = "#{namespace}-prefix.pch" prefix_path = File.join(@sandbox.root,"Target Support Files") prefix_path = File.join(prefix_path,"#{namespace}/") prefix = prefix_path value_item = Hash.new() value_item['suffix'] = suffix value_item['prefix'] = prefix hmap_pch_item = Hash.new() hmap_pch_key = "#{namespace}-prefix.pch" hmap_pch_item[hmap_pch_key] = value_item hmap_pch_string = hmap_pch_item.to_json hmap_pch_string = hmap_pch_string.chop.reverse.chop.reverse return hmap_pch_string end
generate_public_hmap_file(namespace,hmap_public_content)
click to toggle source
# File lib/cocoapods-hmap/hmapcreate/hmap.rb, line 144 def generate_public_hmap_file(namespace,hmap_public_content) hmap_path = File.join(sandbox.headers_root,"headermap/#{namespace}") hmap_json_file = File.join(hmap_path,"#{namespace}_public.json") File.open(hmap_json_file, 'w'){|file| file.write(hmap_public_content)} end
generate_public_hmap_item(namespace, relative_header_path,pod_module_name)
click to toggle source
# File lib/cocoapods-hmap/hmapcreate/hmap.rb, line 96 def generate_public_hmap_item(namespace, relative_header_path,pod_module_name) #----------下面面是通过尖括号引用<PodA/classA.h>----------------# suffix = relative_header_path.basename.to_s #prefix的计算 absolute_source = (@sandbox.root + relative_header_path) prefix = File.join(absolute_source.dirname,'/') value_item = Hash.new() value_item["prefix"] = prefix value_item["suffix"] = suffix #如果有module_name这里的key要修改为对应的key 暂时修改这里改为module/class 或者直接添加module/key module_header_name = namespace + relative_header_path.basename module_header_name = File.join("#{pod_module_name}",relative_header_path.basename) unless pod_module_name.empty? hmap_module_key = module_header_name.to_s hmap_module_item = Hash.new() hmap_module_item[hmap_module_key] = value_item require 'json' hmap_module_string = hmap_module_item.to_json hmap_module_string = hmap_module_string.chop.reverse.chop.reverse #----------下面是通过双引号引用classA.h 模块内部的使用方法----------------# mark_value_item = Hash.new() mark_value_item["suffix"] = suffix mark_value_item["prefix"] = prefix hmap_mark_key = relative_header_path.basename hmap_mark_key = hmap_mark_key.to_s hmap_mark_item = Hash.new() hmap_mark_item[hmap_mark_key] = mark_value_item hmap_mark_string = hmap_mark_item.to_json hmap_mark_string = hmap_mark_string.chop.reverse.chop.reverse hmap_string = "#{hmap_module_string}" + ",\n" + "#{hmap_mark_string}" return hmap_string end
link_headers()
click to toggle source
# File lib/cocoapods-hmap/hmapcreate/hmap.rb, line 6 def link_headers pod_targets.each do |pod_target| # When integrating Pod as frameworks, built Pods are built into # frameworks, whose headers are included inside the built # framework. Those headers do not need to be linked from the # sandbox. next if pod_target.build_as_framework? && pod_target.should_build? hmap_own_content = "" #双引号的引用 hmap_public_content = "" #<>的引用 pod_target_header_mappings = pod_target.header_mappings_by_file_accessor.values pod_target_header_mappings.each do |header_mappings| header_mappings.each do |namespaced_path, files| # pod_target.build_headers.add_files(namespaced_path, files) hmap_items = add_files(namespaced_path,files,pod_target.product_module_name) hmap_own_item = hmap_items[0] hmap_public_item = hmap_items[-1] hmap_own_content = hmap_own_content + "#{hmap_own_item},\n" hmap_public_content = hmap_public_content + "#{hmap_public_item},\n" end end #生成双引号的引用的hmap及json 只有双引号引用的key 里面加一个pch相关的key hmap_own_content = hmap_own_content.chomp.chop pch_item = generate_pch_hmap_item(pod_target) hmap_own_content = hmap_own_content + ",\n#{pch_item}" hmap_own_content = "{" + "\n #{hmap_own_content}\n" + "}" generate_own_hmap_file(pod_target,hmap_own_content) #生成<>引用的json 既有双引号的引用也有<>引用的Key hmap_public_content = hmap_public_content.chomp.chop if hmap_public_content.size == 0 hmap_public_content = "" else hmap_public_content = "{" + "\n #{hmap_public_content}\n" + "}" end generate_public_hmap_file(pod_target,hmap_public_content) # public_header_mappings = pod_target.public_header_mappings_by_file_accessor.values # public_header_mappings.each do |header_mappings| # header_mappings.each do |namespaced_path, files| # sandbox.public_headers.add_files(namespaced_path, files) # end # end end end