Class: Pod::DyInstaller::Xcode::PodsProjectGenerator

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

Overview

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

Defined Under Namespace

Classes: AggregateTargetInstaller, FileReferencesInstaller, PodTargetInstaller, PodTargetIntegrator, TargetInstaller

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initialize a new instance

Parameters:

  • aggregate_targets (Array<AggregateTarget>)

    @see aggregate_targets

  • sandbox (Sandbox)

    @see sandbox

  • pod_targets (Array<PodTarget>)

    @see pod_targets

  • analysis_result (Analyzer)

    @see analysis_result

  • installation_options (InstallationOptions)

    @see installation_options

  • config (Config)

    @see config



53
54
55
56
57
58
59
60
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 53

def initialize(aggregate_targets, sandbox, pod_targets, analysis_result, installation_options, config)
  @aggregate_targets = aggregate_targets
  @sandbox = sandbox
  @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.



21
22
23
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 21

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.



34
35
36
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 34

def analysis_result
  @analysis_result
end

#configConfig (readonly)

Returns the global CocoaPods configuration.

Returns:

  • (Config)

    the global CocoaPods configuration.



42
43
44
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 42

def config
  @config
end

#installation_optionsInstallationOptions (readonly)

Returns the installation options from the Podfile.

Returns:



38
39
40
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 38

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.



29
30
31
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 29

def pod_targets
  @pod_targets
end

#projectPod::Project (readonly)

Returns the ‘Pods/Pods.xcodeproj` project.

Returns:

  • (Pod::Project)

    the ‘Pods/Pods.xcodeproj` project.



15
16
17
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 15

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.



25
26
27
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 25

def sandbox
  @sandbox
end

Instance Method Details

#generate!Object



62
63
64
65
66
67
68
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 62

def generate!
  prepare
  install_file_references
  install_libraries
  integrate_targets
  set_target_dependencies
end

#share_development_pod_schemesvoid

This method returns an undefined value.

Shares schemes of development Pods.



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 93

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



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/pod/installer/xcode/pods_project_generator.rb', line 70

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]
    project.recreate_user_schemes(false) do |scheme, target|
      next unless library_product_types.include? target.symbol_type
      pod_target = pod_targets.find { |pt| pt.native_target == target }
      next if pod_target.nil? || pod_target.test_native_targets.empty?
      pod_target.test_native_targets.each { |test_native_target| scheme.add_test_target(test_native_target) }
    end
    project.save
  end
end