Method: Pod::PodTarget#scoped

Defined in:
lib/cocoapods/target/pod_target.rb

#scoped(cache = {}) ⇒ Array<PodTarget>

Scopes the current target based on the existing pod targets within the cache.

Parameters:

  • cache (Hash{Array => PodTarget}) (defaults to: {})

    the cached target for a previously scoped target.

Returns:

  • (Array<PodTarget>)

    a scoped copy for each target definition.



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/cocoapods/target/pod_target.rb', line 169

def scoped(cache = {})
  target_definitions.map do |target_definition|
    cache_key = [specs, target_definition]
    cache[cache_key] ||= begin
      target = PodTarget.new(sandbox, build_type, user_build_configurations, archs, platform, specs,
                             [target_definition], file_accessors, target_definition.label, swift_version)
      scope_dependent_targets = ->(dependent_targets) do
        dependent_targets.flat_map do |pod_target|
          pod_target.scoped(cache).select { |pt| pt.target_definitions == [target_definition] }
        end
      end

      target.dependent_targets_by_config = Hash[dependent_targets_by_config.map { |k, v| [k, scope_dependent_targets[v]] }]
      target.test_dependent_targets_by_spec_name_by_config = Hash[test_dependent_targets_by_spec_name_by_config.map do |spec_name, test_pod_targets_by_config|
        [spec_name, Hash[test_pod_targets_by_config.map { |k, v| [k, scope_dependent_targets[v]] }]]
      end]
      target.app_dependent_targets_by_spec_name_by_config = Hash[app_dependent_targets_by_spec_name_by_config.map do |spec_name, app_pod_targets_by_config|
        [spec_name, Hash[app_pod_targets_by_config.map { |k, v| [k, scope_dependent_targets[v]] }]]
      end]
      target.test_app_hosts_by_spec = Hash[test_app_hosts_by_spec.map do |spec, (app_host_spec, app_pod_target)|
        [spec, [app_host_spec, app_pod_target.scoped(cache).find { |pt| pt.target_definitions == [target_definition] }]]
      end]
      target
    end
  end
end