Class: Pod::Command::CleanBuildPhasesScripts

Inherits:
Pod::Command show all
Defined in:
lib/cocoapods-clean_build_phases_scripts/command/clean_build_phases_scripts.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CleanBuildPhasesScripts



15
16
17
18
# File 'lib/cocoapods-clean_build_phases_scripts/command/clean_build_phases_scripts.rb', line 15

def initialize(argv)
  @xcodeproj_path = argv ? argv.option('xcodeproj') : nil
  super
end

Class Method Details

.optionsObject



11
12
13
# File 'lib/cocoapods-clean_build_phases_scripts/command/clean_build_phases_scripts.rb', line 11

def self.options
  [ ['--xcodeproj=PATH', '.xcodeproj path'] ].concat(super)
end

Instance Method Details

#clean(project_path) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cocoapods-clean_build_phases_scripts/command/clean_build_phases_scripts.rb', line 36

def clean(project_path)
  xcode_project = Xcodeproj::Project.open(project_path)
  xcode_project.targets.each do |target|
    phase_name = '[CP] Copy Pods Resources'
    target.shell_script_build_phases.select { |phase| phase.name && phase.name.end_with?(phase_name) }.each do |phase|
          puts "Removing input/output paths from script '#{phase.name}' in target '#{target.name}'"
          phase.input_paths = []
          phase.output_paths = []
    end
  end
  xcode_project.save        
end

#runObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cocoapods-clean_build_phases_scripts/command/clean_build_phases_scripts.rb', line 24

def run
  if @xcodeproj_path 
    clean(@xcodeproj_path)
  else
    projects = Dir.glob("**/*.xcodeproj")
    projects.each do |project_path|
      puts "Checking project #{project_path}"
      clean(project_path)
    end
  end
end

#validate!Object



20
21
22
# File 'lib/cocoapods-clean_build_phases_scripts/command/clean_build_phases_scripts.rb', line 20

def validate!
  super
end