Class: Pod::PrebuildSandbox
- Defined in:
- lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb
Class Method Summary collapse
-
.from_standard_sanbox_path(path) ⇒ Object
- String
-
standard_sandbox_path.
- .from_standard_sandbox(sandbox) ⇒ Object
- .replace_content_file(path, name) ⇒ Object
- .replace_tagert_copy_source_sh(installer_context) ⇒ Object
Instance Method Summary collapse
- #existed_target_names_for_pod_name(pod_name) ⇒ Object
- #existed_target_version_for_pod_name(pod_name) ⇒ Object
- #exsited_framework_pod_names ⇒ Object
- #exsited_framework_target_names ⇒ Object
-
#framework_folder_path_for_target_name(name) ⇒ Pathname
The folder containing the framework file.
- #generate_framework_path ⇒ Object
- #real_bundle_path_for_pod(path) ⇒ Object
- #save_pod_name_for_target(target) ⇒ Object
- #standard_sanbox_path ⇒ Object
Class Method Details
.from_standard_sanbox_path(path) ⇒ Object
- String
-
standard_sandbox_path
36 37 38 39 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 36 def self.from_standard_sanbox_path(path) prebuild_sandbox_path = Pathname.new(path).realpath + "_Prebuild" self.new(prebuild_sandbox_path) end |
.from_standard_sandbox(sandbox) ⇒ Object
41 42 43 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 41 def self.from_standard_sandbox(sandbox) self.from_standard_sanbox_path(sandbox.root) end |
.replace_content_file(path, name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 24 def self.replace_content_file(path, name) ostr = "install_resource \"${BUILT_PRODUCTS_DIR}/#{name}" nstr = "install_resource \"${PODS_ROOT}/#{name}" File.open(path,"r:utf-8") do |lines| #r:utf-8表示以utf-8编码读取文件,要与当前代码文件的编码相同 buffer = lines.read.gsub(ostr,nstr) #将文件中所有的ostr替换为nstr,并将替换后文件内容赋值给buffer File.open(path,"w"){|l| #以写的方式打开文件,将buffer覆盖写入文件 l.write(buffer) } end end |
.replace_tagert_copy_source_sh(installer_context) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 6 def self.replace_tagert_copy_source_sh(installer_context) standard_sandbox = installer_context.sandbox prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox) list = prebuild_sandbox.exsited_framework_target_names installer_context.umbrella_targets.each do |um| um.user_targets.each do |target| tn = "Pods-#{target.name}" dir = Pathname.new(File.join(installer_context.sandbox.root,"Target Support Files", tn)) sh_path = File.join(dir, "#{tn}-resources.sh") if File.exists?(sh_path) list.each do |tarname| replace_content_file sh_path, tarname end end end end end |
Instance Method Details
#existed_target_names_for_pod_name(pod_name) ⇒ Object
66 67 68 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 66 def existed_target_names_for_pod_name(pod_name) exsited_framework_name_pairs.select {|pair| pair[1] == pod_name }.map { |pair| pair[0]} end |
#existed_target_version_for_pod_name(pod_name) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 70 def existed_target_version_for_pod_name(pod_name) folder = framework_folder_path_for_target_name(pod_name) return "" unless folder.exist? flag_file_path = folder + "#{pod_name}.pod_name" return "" unless flag_file_path.exist? version = File.read(flag_file_path) version end |
#exsited_framework_pod_names ⇒ Object
63 64 65 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 63 def exsited_framework_pod_names exsited_framework_name_pairs.map {|pair| pair[1]}.uniq end |
#exsited_framework_target_names ⇒ Object
60 61 62 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 60 def exsited_framework_target_names exsited_framework_name_pairs.map {|pair| pair[0]}.uniq end |
#framework_folder_path_for_target_name(name) ⇒ Pathname
Returns the folder containing the framework file.
55 56 57 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 55 def framework_folder_path_for_target_name(name) self.generate_framework_path + name end |
#generate_framework_path ⇒ Object
49 50 51 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 49 def generate_framework_path self.root + "GeneratedFrameworks" end |
#real_bundle_path_for_pod(path) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 86 def real_bundle_path_for_pod(path) tindex = path.index('/') count = path.length - tindex temp = path[tindex,count] rp = "#{self.root}#{temp}" rp end |
#save_pod_name_for_target(target) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 79 def save_pod_name_for_target(target) folder = framework_folder_path_for_target_name(target.name) return unless folder.exist? flag_file_path = folder + "#{target.pod_name}.pod_name" File.write(flag_file_path.to_s, "#{target.version}") end |
#standard_sanbox_path ⇒ Object
45 46 47 |
# File 'lib/cocoapods-xlbuild/helper/prebuild_sandbox.rb', line 45 def standard_sanbox_path self.root.parent end |