Module: Pod::PodUtil
- Includes:
- Config::Mixin
- Included in:
- Frameworker, MutiFrameworker, XBuilder, XBuilder::XcodeProjHelper
- Defined in:
- lib/cocoapods-framework/util/pod_util.rb
Instance Method Summary collapse
- #build_static_sandbox ⇒ Object
- #fix_header_file(spec_hash, xcframework_path) ⇒ Object
- #generic_new_podspec_hash(spec) ⇒ Object
- #installation_root(sandbox, spec, subspecs, sources, use_frameworks = true, use_modular_headers = true, enable_bitcode = false) ⇒ Object
- #installation_root_muti(sandbox, configs, sources, use_frameworks = true, use_modular_headers = true, enable_bitcode = false) ⇒ Object
- #muti_config_with_file(path) ⇒ Object
- #podfile_from_muti_configs(configs, sources, use_frameworks = true, use_modular_headers = true) ⇒ Object
- #podfile_from_spec(path, spec, subspecs, sources, use_frameworks = true, use_modular_headers = true) ⇒ Object
- #spec_with_name(name) ⇒ Object
- #spec_with_path(path) ⇒ Object
- #to_native_platform(name) ⇒ Object
Instance Method Details
#build_static_sandbox ⇒ Object
62 63 64 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 62 def build_static_sandbox Sandbox.new(config.sandbox_root) end |
#fix_header_file(spec_hash, xcframework_path) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 233 def fix_header_file spec_hash, xcframework_path puts "Dir.glob(#{xcframework_path}/*/) : #{Dir.glob("#{xcframework_path}/*/")}" Dir.glob("#{xcframework_path}/*/").each do |file| ['ios','macos','tvos', 'watchos'].each do |prefix| last_path = file.split("/").last if last_path =~ /#{prefix}/ and not last_path =~ /simulator/ platform = to_native_platform prefix if spec_hash[platform] spec_hash[platform]["public_header_files"] = "#{spec_hash[:vendored_frameworks]}/#{last_path}/*/Headers/*.h" spec_hash[platform]["source_files"] = "#{spec_hash[:vendored_frameworks]}/#{last_path}/*/Headers/*.h" else spec_hash[platform] = { "public_header_files" => "#{spec_hash[:vendored_frameworks]}/#{last_path}/*/Headers/*.h", "source_files" => "#{spec_hash[:vendored_frameworks]}/#{last_path}/*/Headers/*.h" } end end end end puts spec_hash.to_json spec_hash end |
#generic_new_podspec_hash(spec) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 208 def generic_new_podspec_hash spec spec_hash = spec.to_hash [ "source_files", "resources", "resource_bundles", "prefix_header_contents", "prefix_header_file", "header_dir", "header_mappings_dir", "script_phase", "public_header_files", "private_header_files", "vendored_frameworks", "vendored_libraries", "exclude_files", "preserve_paths", "module_map", "subspec" ].each do |key| spec_hash.delete "#{key}" end spec_hash end |
#installation_root(sandbox, spec, subspecs, sources, use_frameworks = true, use_modular_headers = true, enable_bitcode = false) ⇒ Object
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 94 95 96 97 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 66 def installation_root sandbox, spec, subspecs, sources,use_frameworks = true,use_modular_headers = true, enable_bitcode = false podfile = podfile_from_spec( @path, spec, subspecs, sources, use_frameworks, use_modular_headers ) installer = Installer.new(sandbox, podfile) installer.repo_update = true installer.install! unless installer.nil? installer.pods_project.targets.each do |target| target.build_configurations.each do |configuration| if enable_bitcode && configuration.name == "Release" configuration.build_settings['ENABLE_BITCODE'] = 'YES' configuration.build_settings['BITCODE_GENERATION_MODE'] = 'bitcode' end end if target.name == spec.name target.build_configurations.each do |configuration| configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO' end end end installer.pods_project.save end installer end |
#installation_root_muti(sandbox, configs, sources, use_frameworks = true, use_modular_headers = true, enable_bitcode = false) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 99 def installation_root_muti sandbox, configs, sources, use_frameworks = true, use_modular_headers = true, enable_bitcode = false podfile = podfile_from_muti_configs( configs, sources, use_frameworks, use_modular_headers ) installer = Installer.new(sandbox, podfile) installer.repo_update = true installer.install! specs = configs.map do |cfg| cfg["name"] end unless installer.nil? installer.pods_project.targets.each do |target| target.build_configurations.each do |configuration| if enable_bitcode && configuration.name == "Release" configuration.build_settings['ENABLE_BITCODE'] = 'YES' configuration.build_settings['BITCODE_GENERATION_MODE'] = 'bitcode' end end if specs.include? target.name target.build_configurations.each do |configuration| configuration.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO' end end end installer.pods_project.save end installer end |
#muti_config_with_file(path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 19 def muti_config_with_file(path) return nil if path.nil? path = Pathname.new(path) path = Pathname.new(Dir.pwd).join(path) unless path.absolute? @path = path. content = File.open(path, 'rb').read result = JSON.parse content if not result.is_a? Array UI.error "#{path} format not support" exit -1 end result end |
#podfile_from_muti_configs(configs, sources, use_frameworks = true, use_modular_headers = true) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 163 def podfile_from_muti_configs configs, sources, use_frameworks = true, use_modular_headers = true installation_root = config.installation_root.to_s static_library_enable = config.static_library_enable? Pod::Podfile.new do sources.each {|s| source s} configs.each do |cfg| pod_spec_path = installation_root + "/#{cfg["name"]}/#{cfg["name"]}.podspec" pod_spec_json_path = pod_spec_path + ".json" (Pathname.glob(pod_spec_path) + Pathname.glob(pod_spec_json_path)).each do |real_path| spec = Pod::Specification.from_file real_path.to_s = Hash.new [:podspec] = real_path.to_s if cfg["subspecs"] [:subspecs] = cfg["subspecs"] else [:subspecs] = spec.subspecs.map do |sub| sub.base_name end end # 非常奇怪,如果传一个空的数组过去就会出问题!! if [:subspecs].length == 0 [:subspecs] = nil end spec.available_platforms.each do |plt| target "#{spec.name}-#{plt.name}" do puts "#{plt.name} #{spec.name} #{}" platform(plt.name, spec.deployment_target(plt.name)) pod(spec.name, ) end end end end install!('cocoapods', :integrate_targets => false, :deterministic_uuids => false) if static_library_enable use_frameworks! :linkage => :static if use_frameworks else use_frameworks! if use_frameworks end use_modular_headers! if use_modular_headers end end |
#podfile_from_spec(path, spec, subspecs, sources, use_frameworks = true, use_modular_headers = true) ⇒ Object
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 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 132 def podfile_from_spec path, spec, subspecs, sources, use_frameworks = true, use_modular_headers=true = Hash.new [:podspec] = path.to_s [:subspecs] = spec.subspecs.map do |sub| sub.base_name end [:subspecs] = subspecs if subspecs # 非常奇怪,如果传一个空的数组过去就会出问题!! if [:subspecs].length == 0 [:subspecs] = nil end static_library_enable = config.static_library_enable? Pod::Podfile.new do sources.each {|s| source s} spec.available_platforms.each do |plt| target "#{spec.name}-#{plt.name}" do platform(plt.name, spec.deployment_target(plt.name)) pod(spec.name, ) end end install!('cocoapods',:integrate_targets => false,:deterministic_uuids => false) if static_library_enable use_frameworks! :linkage => :static if use_frameworks else use_frameworks! if use_frameworks end use_modular_headers! if use_modular_headers end end |
#spec_with_name(name) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 53 def spec_with_name(name) return if name.nil? set = Pod::Config.instance.sources_manager.search(Dependency.new(name)) return nil if set.nil? set.specification.root end |
#spec_with_path(path) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 33 def spec_with_path(path) return if path.nil? path = Pathname.new(path) path = Pathname.new(Dir.pwd).join(path) unless path.absolute? return unless path.exist? @path = path. if @path.directory? raise @path + ': is a directory.' return end unless ['.podspec', '.json'].include? @path.extname raise @path + ': is not a podspec.' return end Specification.from_file(@path) end |
#to_native_platform(name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cocoapods-framework/util/pod_util.rb', line 5 def to_native_platform name case name when 'iphoneos' then 'ios' when 'macOS' then 'osx' when 'appletvos' then 'tvos' when 'watchos' then 'watchos' when 'ios' then 'ios' when 'macos' then 'osx' when 'tvos' then 'tvos' else name end end |