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

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

Overview

A simple container produced after a target installation is completed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, native_target, resource_bundle_targets = [], test_native_targets = [], test_resource_bundle_targets = {}, test_app_host_targets = [], app_native_targets = {}, app_resource_bundle_targets = {}) ⇒ TargetInstallationResult

Initialize a new instance

Parameters:

  • target (Target)

    @see #target

  • native_target (PBXNativeTarget)

    @see #native_target

  • resource_bundle_targets (Array<PBXNativeTarget>) (defaults to: [])

    @see #resource_bundle_targets

  • test_native_targets (Array<PBXNativeTarget>) (defaults to: [])

    @see #test_native_targets

  • test_resource_bundle_targets (Hash{String=>Array<PBXNativeTarget>}) (defaults to: {})

    @see #test_resource_bundle_targets

  • test_app_host_targets (Array<PBXNativeTarget>) (defaults to: [])

    @see #test_app_host_targets

  • app_native_targets (Hash{Specification => PBXNativeTarget}) (defaults to: {})

    @see #app_native_targets

  • app_resource_bundle_targets (Hash{String=>Array<PBXNativeTarget>}) (defaults to: {})

    @see #app_resource_bundle_targets



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

def initialize(target, native_target, resource_bundle_targets = [], test_native_targets = [],
               test_resource_bundle_targets = {}, test_app_host_targets = [],
               app_native_targets = {}, app_resource_bundle_targets = {})
  @target = target
  @native_target = native_target
  @resource_bundle_targets = resource_bundle_targets
  @test_native_targets = test_native_targets
  @test_resource_bundle_targets = test_resource_bundle_targets
  @test_app_host_targets = test_app_host_targets
  @app_native_targets = app_native_targets
  @app_resource_bundle_targets = app_resource_bundle_targets
end

Instance Attribute Details

#app_native_targetsHash{Specification => PBXNativeTarget} (readonly)

Returns app_native_targets The app native targets that were produced for this target. Can be empty if there were no app native targets created (e.g. no app specs present).

Returns:

  • (Hash{Specification => PBXNativeTarget})

    app_native_targets The app native targets that were produced for this target. Can be empty if there were no app native targets created (e.g. no app specs present).



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

def app_native_targets
  @app_native_targets
end

#app_resource_bundle_targetsHash{String=>Array<PBXNativeTarget>} (readonly)

Returns app_resource_bundle_targets The app resource bundle targets that were produced for this target keyed by app spec name. Can be empty if the target had no resource bundles for any apps.

Returns:

  • (Hash{String=>Array<PBXNativeTarget>})

    app_resource_bundle_targets The app resource bundle targets that were produced for this target keyed by app spec name. Can be empty if the target had no resource bundles for any apps.



51
52
53
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 51

def app_resource_bundle_targets
  @app_resource_bundle_targets
end

#native_targetPBXNativeTarget (readonly)

Returns native_target The native target that was produced for this target.

Returns:

  • (PBXNativeTarget)

    native_target The native target that was produced for this target.



16
17
18
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 16

def native_target
  @native_target
end

#resource_bundle_targetsArray<PBXNativeTarget> (readonly)

Returns resource_bundle_targets The resource bundle targets that were produced for this target. Can be empty if the target had no resource bundles.

Returns:

  • (Array<PBXNativeTarget>)

    resource_bundle_targets The resource bundle targets that were produced for this target. Can be empty if the target had no resource bundles.



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

def resource_bundle_targets
  @resource_bundle_targets
end

#targetTarget (readonly)

Returns target The target this installation result is for.

Returns:

  • (Target)

    target The target this installation result is for.



11
12
13
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 11

def target
  @target
end

#test_app_host_targetsArray<PBXNativeTarget> (readonly)

Returns test_app_host_targets The test app host native targets that were produced for this target. Can be empty.

Returns:

  • (Array<PBXNativeTarget>)

    test_app_host_targets The test app host native targets that were produced for this target. Can be empty.



39
40
41
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 39

def test_app_host_targets
  @test_app_host_targets
end

#test_native_targetsArray<PBXNativeTarget> (readonly)

Returns test_native_targets The test native targets that were produced for this target. Can be empty if there were no test native targets created (e.g. no test specs present).

Returns:

  • (Array<PBXNativeTarget>)

    test_native_targets The test native targets that were produced for this target. Can be empty if there were no test native targets created (e.g. no test specs present).



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

def test_native_targets
  @test_native_targets
end

#test_resource_bundle_targetsHash{String=>Array<PBXNativeTarget>} (readonly)

Returns test_resource_bundle_targets The test resource bundle targets that were produced for this target keyed by test spec name. Can be empty if the target had no resource bundles for any tests.

Returns:

  • (Hash{String=>Array<PBXNativeTarget>})

    test_resource_bundle_targets The test resource bundle targets that were produced for this target keyed by test spec name. Can be empty if the target had no resource bundles for any tests.



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

def test_resource_bundle_targets
  @test_resource_bundle_targets
end

Instance Method Details

#app_host_target_labelled(label) ⇒ PBXNativeTarget

Returns the app host target with the given target label.

Parameters:

  • label (String)

    the label of the app host target.

Returns:

  • (PBXNativeTarget)

    the app host target with the given target label.



117
118
119
120
121
122
123
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 117

def app_host_target_labelled(label)
  app_native_targets.values.find do |app_native_target|
    app_native_target.name == label
  end || test_app_host_targets.find do |app_native_target|
    app_native_target.name == label
  end
end

#app_native_target_from_spec(spec) ⇒ Object (private)



133
134
135
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 133

def app_native_target_from_spec(spec)
  app_native_targets[spec]
end

#app_specs_by_native_targetHash{PBXNativeTarget => Specification}

Returns a hash where the keys are the app native targets and the value is the app spec associated with this native target.

Returns:

  • (Hash{PBXNativeTarget => Specification})

    a hash where the keys are the app native targets and the value is the app spec associated with this native target.



101
102
103
104
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 101

def app_specs_by_native_target
  app_specs_by_native_target = Hash[target.app_specs.map { |spec| [app_native_target_from_spec(spec), spec] }]
  app_specs_by_native_target.delete_if { |k, _| k.nil? }
end

#native_target_for_spec(spec) ⇒ PBXNativeTarget, Nil

Returns the corresponding native target to use based on the provided specification.

Parameters:

  • spec (Specification)

    The specification to base from in order to find the native target.

Returns:

  • (PBXNativeTarget, Nil)

    the native target to use or nil if none is found.



84
85
86
87
88
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 84

def native_target_for_spec(spec)
  return native_target if spec.library_specification?
  return test_native_target_from_spec(spec) if spec.test_specification?
  app_native_target_from_spec(spec) if spec.app_specification?
end

#non_library_specs_by_native_targetHash{PBXNativeTarget => Specification}

Returns a hash where the keys are the native targets and the value is the non-library spec associated with this native target.

Returns:

  • (Hash{PBXNativeTarget => Specification})

    a hash where the keys are the native targets and the value is the non-library spec associated with this native target.



109
110
111
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 109

def non_library_specs_by_native_target
  test_specs_by_native_target.merge(app_specs_by_native_target)
end

#test_native_target_from_spec(spec) ⇒ Object (private)



127
128
129
130
131
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 127

def test_native_target_from_spec(spec)
  test_native_targets.find do |test_native_target|
    test_native_target.name == target.test_target_label(spec)
  end
end

#test_specs_by_native_targetHash{PBXNativeTarget => Specification}

Returns a hash where the keys are the test native targets and the value is the test spec associated with this native target.

Returns:

  • (Hash{PBXNativeTarget => Specification})

    a hash where the keys are the test native targets and the value is the test spec associated with this native target.



93
94
95
96
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 93

def test_specs_by_native_target
  test_specs_by_native_target = Hash[target.test_specs.map { |spec| [test_native_target_from_spec(spec), spec] }]
  test_specs_by_native_target.delete_if { |k, _| k.nil? }
end