Class: PBXProjParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ccios/pbxproj_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_path, config) ⇒ PBXProjParser

Returns a new instance of PBXProjParser.



8
9
10
11
12
# File 'lib/ccios/pbxproj_parser.rb', line 8

def initialize(source_path, config)
  @source_path = source_path
  @config = config
  @projects = {}
end

Instance Attribute Details

#source_pathObject

Returns the value of attribute source_path.



6
7
8
# File 'lib/ccios/pbxproj_parser.rb', line 6

def source_path
  @source_path
end

Instance Method Details

#project_for(path) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/ccios/pbxproj_parser.rb', line 20

def project_for(path)
  module_project_path = File.join(source_path, path)
  resolved_module_project_path = Dir.glob(module_project_path).first
  if !File.exist?(resolved_module_project_path)
    raise "[Error] There is no xcodeproj at path #{module_project_path}"
  end
  @projects[module_project_path] ||= Xcodeproj::Project.open(resolved_module_project_path)
end

#saveObject



14
15
16
17
18
# File 'lib/ccios/pbxproj_parser.rb', line 14

def save
  @projects.each do |path, value|
      value.save
  end
end

#target_for(project, target_name) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/ccios/pbxproj_parser.rb', line 29

def target_for(project, target_name)
  if target_name.blank?
    project.targets.find { |t| t.product_type == "com.apple.product-type.application" }
  else
    project.targets.find { |t| t.name == target_name }
  end
end