module Pod class Lockfile def detect_changes_with_podfile(podfile) result = {} [:added, :changed, :removed, :unchanged].each { |k| result[k] = [] } installed_deps = {} dependencies.each do |dep| name = dep.root_name installed_deps[name] ||= dependencies_to_lock_pod_named(name) end installed_deps = installed_deps.values.flatten(1).group_by(&:name) podfile_dependencies = podfile.dependencies podfile_dependencies_by_name = podfile_dependencies.group_by(&:name) all_dep_names = (dependencies + podfile_dependencies).map(&:name).uniq all_dep_names.each do |name| installed_dep = installed_deps[name] installed_dep &&= installed_dep.first # 需要将二进制版本的 specific_version 最后一位去掉,否则二进制下依赖解析很慢 unless installed_dep.nil? installed_dep_version = installed_dep.specific_version.to_s if installed_dep_version.include?('bin') req_arr = installed_dep_version.split('.').delete_if { |r| r.include?('bin') } installed_dep_version = req_arr.join('.') installed_dep.specific_version = Pod::Version.create(installed_dep_version) end end podfile_dep = podfile_dependencies_by_name[name] podfile_dep &&= podfile_dep.first if installed_dep.nil? then key = :added elsif podfile_dep.nil? then key = :removed elsif podfile_dep.compatible?(installed_dep) then key = :unchanged else key = :changed end result[key] << name end result end end end