Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom ordering of script phases (#204) #210

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion defaults/liftoffrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ strict_prompts: false
deployment_target: 8.0

run_script_phases:
- todo.sh: Warn for TODO and FIXME comments
- file: todo.sh
name: Warn for TODO and FIXME comments

templates:
- travis.yml: .travis.yml
Expand Down
18 changes: 14 additions & 4 deletions lib/liftoff/xcodeproj_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Liftoff
class XcodeprojHelper
LAST_INDEX = -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the whitespace line above this and add a whitespace line after it.


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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, unfortunately, I think this is the best way to handle this.

target.build_phases.insert(index, build_phase)

xcode_project.save
end
end
Expand Down
14 changes: 13 additions & 1 deletion man/liftoffrc.5
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,26 @@ for more information on the format of this key.
.Ic liftoff
installs a single Run Script Build Phase 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
.Ic TODO
or
.Ic FIXME
comments into warnings at compilation time.
.Pp
You can also customize when your build phase is executed by using the following
syntax:
.Bd -literal
- file: todo.sh
name: Warn for TODO and FIXME comments
index: 1
.Ed
.Pp
This will insert the same script phase at the index 1 in the build phase list.
Indexes are zero-based and optional. If you skip it, it will default to the end of the list.
.
.Sh WARNINGS
.Ic liftoff
Expand Down