require 'digest' module CBin module BuildAll class BinHelper include Pod def initialize super @specs_str_md5_hash = Hash.new end # 二进制版本号(x.y.z.bin[md5前6位]) def version(pod_name, original_version, specifications) # 有缓存从缓存中取,没有则新建 if @specs_str_md5_hash[pod_name].nil? specs = specifications.map(&:name).select { |spec| spec.include?(pod_name) && !spec.include?('/Binary') }.sort! specs << xcode_version specs << configuration specs_str = specs.join('') specs_str_md5 = Digest::MD5.hexdigest(specs_str)[0,6] @specs_str_md5_hash[pod_name] = specs_str_md5 else specs_str_md5 = @specs_str_md5_hash[pod_name] end "#{original_version}.bin#{specs_str_md5}" end def xcode_version @xcode_version ||= begin `xcodebuild -version`.split(' ').join('') end end def configuration @configuration ||= begin Pod::Config.instance.podfile.configuration end end def self.xcode_version xcode_version = `xcodebuild -version`.split(' ').join('') xcode_version end def self.configuration Pod::Config.instance.podfile.configuration end end end end