Class: Pod::Installer::Xcode::PodsProjectGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/installer/xcode/pods_project_generator.rb,
lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb,
lib/cocoapods/installer/xcode/pods_project_generator/app_host_installer.rb,
lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb,
lib/cocoapods/installer/xcode/pods_project_generator/pod_target_integrator.rb,
lib/cocoapods/installer/xcode/pods_project_generator/target_installer_helper.rb,
lib/cocoapods/installer/xcode/pods_project_generator/file_references_installer.rb,
lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_installer.rb,
lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb

Overview

The PodsProjectGenerator handles generation of the ‘Pods/Pods.xcodeproj’

Defined Under Namespace

Modules: TargetInstallerHelper Classes: AggregateTargetInstaller, AppHostInstaller, AppHostKey, FileReferencesInstaller, InstallationResults, PodTargetInstaller, PodTargetIntegrator, TargetInstallationResult, TargetInstaller

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sandbox, aggregate_targets, pod_targets, analysis_result, installation_options, config) ⇒ PodsProjectGenerator

Initialize a new instance

Parameters:

  • sandbox (Sandbox)

    @see #sandbox

  • aggregate_targets (Array<AggregateTarget>)

    @see #aggregate_targets

  • pod_targets (Array<PodTarget>)

    @see #pod_targets

  • analysis_result (Analyzer)

    @see #analysis_result

  • installation_options (InstallationOptions)

    @see #installation_options

  • config (Config)

    @see #config



56
57
58
59
60
61
62
63
# File 'lib/cocoapods/installer/xcode/pods_project_generator.rb', line 56

def initialize(sandbox, aggregate_targets, pod_targets, analysis_result, installation_options, config)
  @sandbox = sandbox
  @aggregate_targets = aggregate_targets
  @pod_targets = pod_targets
  @analysis_result = analysis_result
  @installation_options = installation_options
  @config = config
end

Instance Attribute Details

#aggregate_targetsArray<AggregateTarget> (readonly)

Returns The model representations of an aggregation of pod targets generated for a target definition in the Podfile.

Returns:

  • (Array<AggregateTarget>)

    The model representations of an aggregation of pod targets generated for a target definition in the Podfile.



28
29
30
# File 'lib/cocoapods/installer/xcode/pods_project_generator.rb', line 28

def aggregate_targets
  @aggregate_targets
end

#analysis_resultAnalyzer (readonly)

Returns the analyzer which provides the information about what needs to be installed.

Returns:

  • (Analyzer)

    the analyzer which provides the information about what needs to be installed.



37
38
39
# File 'lib/cocoapods/installer/xcode/pods_project_generator.rb', line 37

def analysis_result
  @analysis_result
end

#configConfig (readonly)

Returns the global CocoaPods configuration.

Returns:

  • (Config)

    the global CocoaPods configuration.



45
46
47
# File 'lib/cocoapods/installer/xcode/pods_project_generator.rb', line 45

def config
  @config
end

#installation_optionsInstallationOptions (readonly)

Returns the installation options from the Podfile.

Returns:



41
42
43
# File 'lib/cocoapods/installer/xcode/pods_project_generator.rb', line 41

def installation_options
  @installation_options
end

#pod_targetsArray<PodTarget> (readonly)

Returns The model representations of pod targets.

Returns:

  • (Array<PodTarget>)

    The model representations of pod targets.



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

def pod_targets
  @pod_targets
end

#projectPod::Project (readonly)

Returns the ‘Pods/Pods.xcodeproj` project.

Returns:



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

def project
  @project
end

#sandboxSandbox (readonly)

Returns The sandbox where the Pods should be installed.

Returns:

  • (Sandbox)

    The sandbox where the Pods should be installed.



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

def sandbox
  @sandbox
end

Instance Method Details

#generate!Object



65
66
67
68
69
70
71
72
73
# File 'lib/cocoapods/installer/xcode/pods_project_generator.rb', line 65

def generate!
  prepare
  install_file_references
  @target_installation_results = install_targets
  integrate_targets(@target_installation_results.pod_target_installation_results)
  app_hosts_by_host_key = install_app_hosts
  wire_target_dependencies(@target_installation_results, app_hosts_by_host_key)
  @target_installation_results
end

#share_development_pod_schemesvoid

This method returns an undefined value.

Shares schemes of development Pods.



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/cocoapods/installer/xcode/pods_project_generator.rb', line 106

def share_development_pod_schemes
  development_pod_targets.select(&:should_build?).each do |pod_target|
    next unless share_scheme_for_development_pod?(pod_target.pod_name)
    Xcodeproj::XCScheme.share_scheme(project.path, pod_target.label)
    if pod_target.contains_test_specifications?
      pod_target.supported_test_types.each do |test_type|
        Xcodeproj::XCScheme.share_scheme(project.path, pod_target.test_target_label(test_type))
      end
    end
  end
end

#writeObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/cocoapods/installer/xcode/pods_project_generator.rb', line 75

def write
  UI.message "- Writing Xcode project file to #{UI.path sandbox.project_path}" do
    project.pods.remove_from_project if project.pods.empty?
    project.development_pods.remove_from_project if project.development_pods.empty?
    project.sort(:groups_position => :below)
    if installation_options.deterministic_uuids?
      UI.message('- Generating deterministic UUIDs') { project.predictabilize_uuids }
    end
    library_product_types = [:framework, :dynamic_library, :static_library]

    pod_target_installation_results = @target_installation_results.pod_target_installation_results
    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
    project.save
  end
end