Method: Pod::Podfile::DSL#script_phase

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

#script_phase(options) ⇒ void

This method returns an undefined value.

Adds a script phase to be integrated with this target. A script phase can be used to execute an arbitrary script that can use all Xcode environment variables during execution. A target may include multiple script phases which they will be added in the order they were declared. Deleting a script phase will effectively remove it from the target if it has been added previously.

Examples:

script_phase :name => 'HelloWorldScript', :script => 'echo "Hello World"'
script_phase :name => 'HelloWorldScript', :script => 'puts "Hello World"', :shell_path => '/usr/bin/ruby'

Parameters:

  • options (Hash)

    the options for this script phase.

Options Hash (options):

  • :name (String)

    the name of the script phase. This option is required.

  • :script (String)

    the body of the script to execute. This option is required.

  • :shell_path (String)

    the shell path to use for this script phase, for example ‘/usr/bin/ruby` to use Ruby for this phase.

  • :input_files (Array<String>)

    the input paths to use for this script phase. This is used by Xcode to determine whether to re-execute this script phase if the input paths have changed or not.

  • :output_files (Array<String>)

    the output paths to use for this script phase. This is used by Xcode to avoid re-executing this script phase if none of the output paths have changed.

  • :input_file_lists (Array<String>)

    the input file lists to use for this script phase. This is used by Xcode to determine whether to re-execute this script phase if the input paths have changed or not.

  • :output_file_lists (Array<String>)

    the output file lists to use for this script phase. This is used by Xcode to avoid re-executing this script phase if none of the output paths have changed.

  • :show_env_vars_in_log (Boolean)

    whether this script phase should output the environment variables during execution.

  • :execution_position (Symbol)

    specifies the position of which this script phase should be executed. The currently supported values are: ‘:before_compile`, `:after_compile` and `:any` which is the default.

  • :dependency_file (String)

    specifies the dependency file to use for this script phase.

  • :always_out_of_date (String)

    specifies whether or not this run script will be forced to run even on incremental builds

Raises:

[View source]

464
465
466
467
468
# File 'lib/cocoapods-core/podfile/dsl.rb', line 464

def script_phase(options)
  raise Informative, 'Script phases can only be added within target definitions.' if current_target_definition.root?
  raise Informative, 'Script phases cannot be added to abstract targets.' if current_target_definition.abstract?
  current_target_definition.store_script_phase(options)
end