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 = {}) ⇒ 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



44
45
46
47
48
49
50
51
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 44

def initialize(target, native_target, resource_bundle_targets = [], test_native_targets = [],
               test_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
end

Instance Attribute Details

#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_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

#native_target_for_spec(spec) ⇒ PBXNativeTarget

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)

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



60
61
62
63
# File 'lib/cocoapods/installer/xcode/pods_project_generator/target_installation_result.rb', line 60

def native_target_for_spec(spec)
  return native_target unless spec.test_specification?
  test_native_target_from_spec(spec)
end

#test_specs_by_native_targetHash{Array => Specification}

Returns a hash where the keys are the test native targets and the value an array of all the test specs associated with this native target.

Returns:

  • (Hash{Array => Specification})

    a hash where the keys are the test native targets and the value an array of all the test specs associated with this native target.



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

def test_specs_by_native_target
  test_specs_by_native_target = target.test_specs.group_by do |test_spec|
    test_native_target_from_spec(test_spec)
  end
  test_specs_by_native_target.delete_if { |k, _| k.nil? }
end