CocoaPods 支持 自定义脚本(script_phase)

5,968 阅读1分钟

通过podfile 向target 添加脚本

target XXX do    script_phase :name => 'test',        :script => 'echi "hello world"',        :execution_position => :before_compileend

通过podspec 添加脚本

spec.script_phase = { :name => 'test', :script => 'echo "Hello World"', :execution_position => :before_compile }

效果图

字段含义

SCRIPT_PHASE_REQUIRED_KEYS = [:name, :script]SCRIPT_PHASE_OPTIONAL_KEYS = [:shell_path, :input_files, :output_files, :show_env_vars_in_log, :execution_position]

:name 脚本显示名称
:script 脚本内容
:execution_position 执行位置如:before_compile/:after_compile(编译前还是编译后)
:shell_path 路径
:input_files/:output_files/show_env_vars_in_log 对应自定义脚本的选项

官方文档

podsepc

podfile

CocoaPods