Class: Pod::Installer::Xcode::TargetValidatorTal
- Inherits:
-
TargetValidator
- Object
- TargetValidator
- Pod::Installer::Xcode::TargetValidatorTal
- Defined in:
- lib/cocoapods-install_tal/src/target_validator_tal.rb
Instance Method Summary collapse
-
#initialize(aggregate_targets, pod_targets, auto_fix_conflict = true) ⇒ TargetValidatorTal
constructor
A new instance of TargetValidatorTal.
- #verify_no_duplicate_framework_and_library_names ⇒ Object
- #verify_no_duplicate_names(names, aggregate_target, type, file_accessors) ⇒ Object
Constructor Details
#initialize(aggregate_targets, pod_targets, auto_fix_conflict = true) ⇒ TargetValidatorTal
Returns a new instance of TargetValidatorTal.
6 7 8 9 10 |
# File 'lib/cocoapods-install_tal/src/target_validator_tal.rb', line 6 def initialize(aggregate_targets, pod_targets, auto_fix_conflict = true) @aggregate_targets = aggregate_targets @pod_targets = pod_targets @auto_fix_conflict = auto_fix_conflict end |
Instance Method Details
#verify_no_duplicate_framework_and_library_names ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cocoapods-install_tal/src/target_validator_tal.rb', line 12 def verify_no_duplicate_framework_and_library_names aggregate_targets.each do |aggregate_target| aggregate_target.user_build_configurations.keys.each do |config| pod_targets = aggregate_target.pod_targets_for_build_configuration(config) file_accessors = pod_targets.flat_map(&:file_accessors) frameworks = file_accessors.flat_map(&:vendored_frameworks).uniq.map(&:basename) frameworks += pod_targets.select { |pt| pt.should_build? && pt.requires_frameworks? }.map(&:product_module_name).uniq verify_no_duplicate_names(frameworks, aggregate_target, 'frameworks', file_accessors) libraries = file_accessors.flat_map(&:vendored_libraries).uniq.map(&:basename) libraries += pod_targets.select { |pt| pt.should_build? && !pt.requires_frameworks? }.map(&:product_name) verify_no_duplicate_names(libraries, aggregate_target, 'libraries', file_accessors) end end end |
#verify_no_duplicate_names(names, aggregate_target, type, file_accessors) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cocoapods-install_tal/src/target_validator_tal.rb', line 29 def verify_no_duplicate_names(names, aggregate_target, type, file_accessors) duplicates = names.map { |n| n.to_s.downcase }.group_by { |f| f }.select { |_, v| v.size > 1 }.keys if !duplicates.empty? && @auto_fix_conflict # 移除冲突文件 duplicate_files = Array.new duplicates.each do |d| tmp_duplicate = file_accessors.flat_map(&:vendored_libraries).uniq.find_all { |p| d == p.basename.to_s && File.exist?(p) }.sort || [] duplicate_files << tmp_duplicate end duplicate_files.each do |dfs| if dfs.count > 1 dfs.pop dfs.each do |file| puts "remove confliting file #{file}" FileUtils.rm(file) if File.exist?(file) end end end end if duplicates.empty? && !@auto_fix_conflict raise Informative, "The '#{aggregate_target.label}' target has " \ "#{type} with conflicting names: #{duplicates.to_sentence}." end end |