Method: Pod::Podfile::TargetDefinition#store_script_phase

Defined in:
lib/cocoapods-core/podfile/target_definition.rb

#store_script_phase(options) ⇒ void

This method returns an undefined value.

Stores the script phase to add for this target definition.

Parameters:

  • options (Hash)

    The options to use for this script phase. The required keys are: :name, :script, while the optional keys are: :shell_path, :input_files, :output_files, :show_env_vars_in_log, :execution_position and :dependency_file.



774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
# File 'lib/cocoapods-core/podfile/target_definition.rb', line 774

def store_script_phase(options)
  option_keys = options.keys
  unrecognized_keys = option_keys - Specification::ALL_SCRIPT_PHASE_KEYS
  unless unrecognized_keys.empty?
    raise StandardError, "Unrecognized options `#{unrecognized_keys}` in shell script `#{options[:name]}` within `#{name}` target. " \
      "Available options are `#{Specification::ALL_SCRIPT_PHASE_KEYS}`."
  end
  missing_required_keys = Specification::SCRIPT_PHASE_REQUIRED_KEYS - option_keys
  unless missing_required_keys.empty?
    raise StandardError, "Missing required shell script phase options `#{missing_required_keys.join(', ')}`"
  end
  script_phases_hash = get_hash_value('script_phases', [])
  if script_phases_hash.map { |script_phase_options| script_phase_options[:name] }.include?(options[:name])
    raise StandardError, "Script phase with name `#{options[:name]}` name already present for target `#{name}`."
  end
  options[:execution_position] = :any unless options.key?(:execution_position)
  unless Specification::EXECUTION_POSITION_KEYS.include?(options[:execution_position])
    raise StandardError, "Invalid execution position value `#{options[:execution_position]}` in shell script `#{options[:name]}` within `#{name}` target. " \
      "Available options are `#{Specification::EXECUTION_POSITION_KEYS}`."
  end
  script_phases_hash << options
end