Class: ProjectHelper
- Inherits:
-
Object
- Object
- ProjectHelper
- Defined in:
- lib/project_helper.rb
Constant Summary collapse
- PROJECTS =
Dir.glob('*.xcodeproj')
Instance Method Summary collapse
- #add_shell_script(target, name, script) ⇒ Object
- #duplicate_configurations(configurations_hash) ⇒ Object
- #enable_options(options) ⇒ Object
-
#initialize ⇒ ProjectHelper
constructor
A new instance of ProjectHelper.
- #select_target_for_name(name) ⇒ Object
- #set_build_settings(build_settings) ⇒ Object
Constructor Details
#initialize ⇒ ProjectHelper
Returns a new instance of ProjectHelper.
7 8 9 |
# File 'lib/project_helper.rb', line 7 def initialize @project = Xcodeproj::Project.open(xcode_project_file) end |
Instance Method Details
#add_shell_script(target, name, script) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/project_helper.rb', line 33 def add_shell_script(target, name, script) if target.shell_script_build_phases.to_a.index { |phase| phase.name == name } puts "Skipping adding \"#{name}\" script for target #{target} as it already exist" else target.new_shell_script_build_phase(name).shell_script = script save_changes end end |
#duplicate_configurations(configurations_hash) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/project_helper.rb', line 42 def duplicate_configurations(configurations_hash) configurations_hash.each do |name, base| @project.targets.each do |target| base_configuration, project_configuration = find_configurations(base, target) if !base_configuration || !project_configuration puts "unable to find configurations for #{base}" next end target.build_configurations << clone_configuration(base_configuration, name) @project.build_configurations << clone_configuration(project_configuration, name) end end save_changes end |
#enable_options(options) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/project_helper.rb', line 11 def () @project.build_configurations.each do |configuration| .each do |option| configuration.build_settings[option] = 'YES' end end save_changes end |
#select_target_for_name(name) ⇒ Object
61 62 63 64 65 |
# File 'lib/project_helper.rb', line 61 def select_target_for_name(name) targets = @project.targets.to_a.select { |t| t.name.end_with? name.to_s } targets = @project.targets.to_a if targets.empty? choose_item("Which target should I use for #{name}?", targets) end |
#set_build_settings(build_settings) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/project_helper.rb', line 20 def set_build_settings(build_settings) @project.build_configurations.each do |configuration| build_settings.each do |configuration_name, settings| if configuration_name.to_s.downcase == "crafter_common" || configuration.name.downcase == configuration_name.to_s.downcase settings.each do |key, value| configuration.build_settings[key] = value end end end end save_changes end |