Class: Vendor::XCode::Project

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_folder) ⇒ Project

Returns a new instance of Project.



9
10
11
# File 'lib/vendor/xcode/project.rb', line 9

def initialize(project_folder)
  @project = Xcode.project project_folder
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



7
8
9
# File 'lib/vendor/xcode/project.rb', line 7

def project
  @project
end

Instance Method Details

#install(library, targets) ⇒ Object

Install the library into the project for the selected targets.

Parameters:

  • library (Library)

    the instance that conveys the requirements to install.

  • targets (Array<Symbols>)

    to install this library; The value :all is a special target name that means all targets.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/vendor/xcode/project.rb', line 21

def install(library,targets)
  
  Vendor.ui.info "## Installing __#{library.name} (#{library.version})__\n\n"

  project_targets = project_targets_from_specified_targets(targets)
  
  if project_targets.empty?
    Vendor.ui.warn "* The project '#{project.name}' does not have any matching targets: #{targets.join(", ")}"
    return
  end
  
  library_pathname = "Vendor/#{library.name}"
  
  files_added = create_library_folders_and_groups library_pathname, library.files
  
  resources_added = create_library_folders_and_groups library_pathname, library.resources, 'resource'
  
  frameworks_added = add_required_frameworks_to_project library.frameworks
  
 
  source_files = files_added.find_all {|file| File.extname(file.path.to_s) =~ /\.mm?$/ }

  framework_files = frameworks_added + files_added.find_all {|file| File.extname(file.path.to_s) =~ /\.a$|\.framework$/ }

  
  project_targets.each do |target|
    
    Vendor.ui.info "\n### Configuring Build Target '__#{target.name}__'\n\n"
    
    add_source_files_to_sources_build_phase source_files, target.sources_build_phase, library.per_file_flag
    
    add_resource_files_to_resources_build_phase resources_added, target.resources_build_phase
    
    add_frameworks_to_frameworks_build_phase framework_files, target.framework_build_phase
    
    add_build_settings_to_target_configurations target, library.build_settings
    
  end

  project.save!
  
end