Class: Pod::Installer::Xcode::PodsProjectWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sandbox, projects, pod_target_installation_results, installation_options) ⇒ PodsProjectWriter

Initialize a new instance

Parameters:

  • sandbox (Sandbox)

    @see #sandbox

  • projects (Project)

    @see #project

  • pod_target_installation_results (Hash<String, TargetInstallationResult>)

    @see #pod_target_installation_results

  • installation_options (InstallationOptions)

    @see #installation_options



31
32
33
34
35
36
# File 'lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb', line 31

def initialize(sandbox, projects, pod_target_installation_results, installation_options)
  @sandbox = sandbox
  @projects = projects
  @pod_target_installation_results = pod_target_installation_results
  @installation_options = installation_options
end

Instance Attribute Details

#installation_optionsInstallationOptions (readonly)

Returns installation_options.

Returns:



22
23
24
# File 'lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb', line 22

def installation_options
  @installation_options
end

#pod_target_installation_resultsHash<String, TargetInstallationResult> (readonly)

Returns pod_target_installation_results Hash of pod target name to installation results.

Returns:

  • (Hash<String, TargetInstallationResult>)

    pod_target_installation_results Hash of pod target name to installation results.



18
19
20
# File 'lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb', line 18

def pod_target_installation_results
  @pod_target_installation_results
end

#projectsArray<Project> (readonly)

Returns projects The list project to write.

Returns:

  • (Array<Project>)

    projects The list project to write.



13
14
15
# File 'lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb', line 13

def projects
  @projects
end

#sandboxSandbox (readonly)

Returns sandbox The Pods sandbox instance.

Returns:

  • (Sandbox)

    sandbox The Pods sandbox instance.



8
9
10
# File 'lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb', line 8

def sandbox
  @sandbox
end

Instance Method Details

#write! { ... } ⇒ Object

Writes projects to disk.

Yields:

  • If provided, this block will execute right before writing the projects to disk.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb', line 42

def write!
  cleanup_projects(projects)

  projects.each do |project|
    library_product_types = [:framework, :dynamic_library, :static_library]
    results_by_native_target = Hash[pod_target_installation_results.map do |_, result|
      [result.native_target, result]
    end]
    project.recreate_user_schemes(false) do |scheme, target|
      next unless target.respond_to?(:symbol_type)
      next unless library_product_types.include? target.symbol_type
      installation_result = results_by_native_target[target]
      next unless installation_result
      installation_result.test_native_targets.each do |test_native_target|
        scheme.add_test_target(test_native_target)
      end
    end
  end

  yield if block_given?

  save_projects(projects)
end