Class: Cint::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/cint/project.rb

Overview

Project

Instance Method Summary collapse

Constructor Details

#initialize(project_name) ⇒ Project

Returns a new instance of Project.



5
6
7
8
9
# File 'lib/cint/project.rb', line 5

def initialize(project_name)
  @project = Xcodeproj::Project.open(project_name)
rescue
  error "Project #{project_name} not found"
end

Instance Method Details

#_fix_frameworks_paths(frameworks) ⇒ Object



46
47
48
49
50
# File 'lib/cint/project.rb', line 46

def _fix_frameworks_paths(frameworks)
  frameworks.map do |f|
    f[2..-1]
  end
end

#add_missing_frameworks_to_target(target, frameworks) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cint/project.rb', line 23

def add_missing_frameworks_to_target(target, frameworks)
  
  fs = _fix_frameworks_paths(frameworks)
  fs -= target.frameworks_build_phase.files.map(&:file_ref).select { |ref| !ref.nil? }.map { |f| f.path }

  added_frameworks = []
  files = fs.map do |f|
    file = @project.frameworks_group.files.find { |ff| ff.path == f}
    if file.nil?
      file = @project.frameworks_group.new_file(f) if file.nil?
      added_frameworks << f
    end
    
    file
  end

  files.each do |f|
    target.frameworks_build_phase.add_file_reference(f)
  end
  
  return added_frameworks
end

#add_path(path) ⇒ Object



19
20
21
# File 'lib/cint/project.rb', line 19

def add_path(path)
  @project.add_frameworks_search_path(path)
end

#saveObject



52
53
54
# File 'lib/cint/project.rb', line 52

def save
  @project.save
end

#target_by_name(name) ⇒ Object



15
16
17
# File 'lib/cint/project.rb', line 15

def target_by_name(name)
  @project.targets.find { |t| t.name == name }
end

#targetsObject



11
12
13
# File 'lib/cint/project.rb', line 11

def targets
  @project.targets
end