Class: Ambient::ProjectHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/ambient/project_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ProjectHelper

Returns a new instance of ProjectHelper.



5
6
7
8
9
# File 'lib/ambient/project_helper.rb', line 5

def initialize(path)
  @path = path
  projects = Dir.glob(path + '/*.xcodeproj')
  @project = Xcodeproj::Project.open(projects.first)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/ambient/project_helper.rb', line 3

def path
  @path
end

Instance Method Details



99
100
101
102
103
104
105
106
107
# File 'lib/ambient/project_helper.rb', line 99

def print_info
  puts ""
  puts "Targets:"
  @project.targets.each { |t| puts "- #{t.to_s}" }
  puts ""
  puts "Build configurations:"
  @project.build_configurations.each { |c| puts "- #{c.to_s}" }
  puts ""
end

#process_capabilities(capabilities_hash) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'lib/ambient/project_helper.rb', line 67

def process_capabilities(capabilities_hash)
  capabilities_hash.each do |target_name, capabilities|
    @project.targets.each do |target|
      if target_name == target.to_s
        helper = CapabilitiesHelper.new(@project, target)
        capabilities.each { |c| helper.enable_capability(c) }
      end
    end
  end
end

#process_development_teams(development_teams) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/ambient/project_helper.rb', line 88

def process_development_teams(development_teams)
  development_teams.each do |target_name, development_team|
    @project.targets.each do |target|
      if target_name == target.to_s
        helper = CapabilitiesHelper.new(@project, target)
        helper.set_development_team(development_team)
      end
    end
  end
end

#process_project_options(options) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/ambient/project_helper.rb', line 33

def process_project_options(options)
  @project.build_configurations.each do |configuration|
    options.each do |key, value|
      configuration.build_settings[key] = value
      configuration.build_settings.delete(key) if value == nil
    end
  end
end

#process_scheme_options(options) ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/ambient/project_helper.rb', line 78

def process_scheme_options(options)
  @project.build_configurations.each do |configuration|
    scheme_options = options[configuration.to_s] || {}
    scheme_options.each do |key, value|
      configuration.build_settings[key] = value
      configuration.build_settings.delete(key) if value == nil
    end
  end
end

#process_shared_target_options(shared_target_options) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/ambient/project_helper.rb', line 42

def process_shared_target_options(shared_target_options)
  @project.targets.each do |target|
    options = shared_target_options[target.to_s]
    if options
      @project.build_configurations.each do |configuration|
        target.build_configuration_list.build_settings(configuration.to_s).merge!(options)
      end
    end
  end
end

#process_target_options(target_options) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ambient/project_helper.rb', line 53

def process_target_options(target_options)
  @project.targets.each do |target|
    options = target_options[target.to_s]
    if options
      @project.build_configurations.each do |configuration|
        scheme_options = options[configuration.to_s]
        if scheme_options
          target.build_configuration_list.build_settings(configuration.to_s).merge!(scheme_options)
        end
      end
    end
  end
end

#reset_capabilities_to_defaultsObject



27
28
29
30
31
# File 'lib/ambient/project_helper.rb', line 27

def reset_capabilities_to_defaults
  @project.targets.each do |target|
    CapabilitiesHelper.new(@project, target).clear_capabilities
  end
end

#reset_project_to_defaultsObject



11
12
13
14
15
16
# File 'lib/ambient/project_helper.rb', line 11

def reset_project_to_defaults
  @project.build_configurations.each do |configuration|
    build_settings = configuration.build_settings
    build_settings.each { |k, _| build_settings.delete(k) }
  end
end

#reset_targets_to_defaultsObject



18
19
20
21
22
23
24
25
# File 'lib/ambient/project_helper.rb', line 18

def reset_targets_to_defaults
  @project.targets.each do |target|
    @project.build_configurations.each do |configuration|
      build_settings = target.build_configuration_list.build_settings(configuration.to_s)
      build_settings.each { |k, _| build_settings.delete(k) }
    end
  end
end

#save_changesObject



109
110
111
# File 'lib/ambient/project_helper.rb', line 109

def save_changes
  @project.save
end