class Pod::Generator::CopyResourcesScript

Public Class Methods

new(resources_by_config, platform) click to toggle source
# File lib/pod_builder/podfile/pre_actions_swizzles.rb, line 53
def initialize(resources_by_config, platform)
  resources_by_config.keys.each do |key|
    items = resources_by_config[key]
    items.uniq!

    colliding_resources = items.group_by { |t| File.basename(t) }.values.select { |t| t.count > 1 }

    unless colliding_resources.empty?
      message = ""
      colliding_resources.each do |resources|
        resources.map! { |t| File.expand_path(t.gsub("${PODS_ROOT}", "#{Dir.pwd}/Pods")) }
        # check that files are identical.
        # For files with paths that are resolved (e.g containing ${PODS_ROOT}) we use the file hash
        # we fallback to the filename for the others
        hashes = resources.map { |t| File.exists?(t) ? Digest::MD5.hexdigest(File.read(t)) : File.basename(t) }
        if hashes.uniq.count > 1
          message += resources.join("\n") + "\n"
        end
      end

      unless message.empty?
        message = "\n\nThe following resources have the same name and will collide once copied into application bundle:\n" + message
        raise message
      end
    end

    resources_by_config[key] = items
  end
  
  swz_initialize(resources_by_config, platform)
end
Also aliased as: swz_initialize

Public Instance Methods

swz_initialize(resources_by_config, platform)
Alias for: new