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

Returns a new instance of 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

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cocoapods-clean_build_phases_scripts/command/clean_build_phases_scripts.rb', line 24

def run
  if !@xcodeproj_path 
    @xcodeproj_path = Dir.glob("**/*.xcodeproj").first
  end

  help! 'A xcodeproj file could not found.' unless @xcodeproj_path

  xcode_project = Xcodeproj::Project.open(@xcodeproj_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

#validate!Object



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

def validate!
  super
end