Class: Pod::Command::Util::Unique
- Inherits:
-
Pod::Command::Util
- Object
- Pod::Command
- Pod::Command::Util
- Pod::Command::Util::Unique
- Defined in:
- lib/cocoapods-util/command/cocoapods-extend/unique.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Unique
constructor
A new instance of Unique.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Unique
Returns a new instance of Unique.
20 21 22 23 24 25 26 |
# File 'lib/cocoapods-util/command/cocoapods-extend/unique.rb', line 20 def initialize(argv) @proj_path = argv.shift_argument @target_names = argv.option('targetname', '').split(',') @uniq_compile_sources = argv.flag?('uniq-compile-sources', true) @uniq_bundle_resources = argv.flag?('uniq-bundle-resources', true) super end |
Class Method Details
.options ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/cocoapods-util/command/cocoapods-extend/unique.rb', line 13 def self. [ ['--targetname=TargetName,TargetName', '指定需要操作的Target'], ['--uniq-compile-sources', '对Build Phase中的Compile Sources中文件去重'], ['--uniq-bundle-resources', '对Build Phase中Copy Bundle Resources中资源去重'] ] end |
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cocoapods-util/command/cocoapods-extend/unique.rb', line 33 def run require 'xcodeproj' project = Xcodeproj::Project.open(@proj_path) # uniques array uniq_phases = [] uniq_phases |= ['SourcesBuildPhase'] if @uniq_compile_sources uniq_phases |= ['ResourcesBuildPhase'] if @uniq_bundle_resources project.targets.each do |target| next if @target_names.count > 0 && !@target_names.include?(target.name) target.build_phases.each do |phase| phase.files.uniq! if uniq_phases.include?(phase.to_s) end end project.save puts 'xcodeproj files unique success' end |
#validate! ⇒ Object
28 29 30 31 |
# File 'lib/cocoapods-util/command/cocoapods-extend/unique.rb', line 28 def validate! super help! 'An project.xcodeproj is required.' unless @proj_path end |