Skip to content

Commit

Permalink
Allow custom ordering of script phases
Browse files Browse the repository at this point in the history
Extend the script phase configuration to allow users to specify a
specific index for the build phase.
  • Loading branch information
Juan Pablo Civile authored and gfontenot committed Feb 9, 2015
1 parent a4e8c10 commit 98814ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 4 additions & 2 deletions defaults/liftoffrc
Expand Up @@ -19,8 +19,10 @@ strict_prompts: false
deployment_target: 8.0

run_script_phases:
- todo.sh: Warn for TODO and FIXME comments
- bundle_version.sh: Set version number
- file: todo.sh
name: Warn for TODO and FIXME comments
- file: bundle_version.sh
name: Set version number

templates:
- travis.yml: .travis.yml
Expand Down
18 changes: 14 additions & 4 deletions lib/liftoff/xcodeproj_helper.rb
@@ -1,5 +1,7 @@
module Liftoff
class XcodeprojHelper
LAST_INDEX = -1

def treat_warnings_as_errors(enable_errors)
if enable_errors
puts 'Setting GCC_TREAT_WARNINGS_AS_ERRORS for Release builds'
Expand Down Expand Up @@ -40,9 +42,13 @@ def set_indentation_level(level, use_tabs)
def add_script_phases(scripts)
if scripts
scripts.each do |script|
key, value = script.first
puts "Adding shell script build phase '#{value}'"
add_shell_script_build_phase(file_manager.template_contents(key), value)

file = script['file']
name = script['name']
index = script.fetch('index', LAST_INDEX)

puts "Adding shell script build phase '#{name}'"
add_shell_script_build_phase(file_manager.template_contents(file), name, index)
end
end
end
Expand Down Expand Up @@ -79,10 +85,14 @@ def available_targets
xcode_project.targets.to_a.reject { |t| t.name.end_with?('Tests') }
end

def add_shell_script_build_phase(script, name)
def add_shell_script_build_phase(script, name, index)
if build_phase_does_not_exist_with_name?(name)
build_phase = target.new_shell_script_build_phase(name)
build_phase.shell_script = script

target.build_phases.delete(build_phase)
target.build_phases.insert(index, build_phase)

xcode_project.save
end
end
Expand Down
3 changes: 2 additions & 1 deletion man/liftoffrc.5
Expand Up @@ -301,7 +301,8 @@ for more information on the format of this key.
.Ic liftoff
installs two Run Script Build Phases by default:
.Bd -literal
- todo.sh: Warn for TODO and FIXME comments
- file: todo.sh
name: Warn for TODO and FIXME comments
.Ed
.Pp
This script turns any
Expand Down

0 comments on commit 98814ec

Please sign in to comment.