Class: Pod::SPM::Resolver::Result

Inherits:
Object
  • Object
show all
Includes:
Config::Mixin
Defined in:
lib/cocoapods-spm/resolver/result.rb

Direct Known Subclasses

WritableResult

Defined Under Namespace

Classes: WritableResult

Constant Summary collapse

ATTRS =
{
  :spm_pkgs => [],
  :spm_dependencies_by_target => {},
  :project_pkgs => nil,
}.freeze

Instance Method Summary collapse

Methods included from Config::SPMConfigMixin

#macro_pods, #spm_config

Methods included from Config::PodConfigMixin

#pod_config

Methods included from Config::ProjectConfigMixin

#project_config

Constructor Details

#initialize(options = {}) ⇒ Result

Returns a new instance of Result.



23
24
25
26
27
# File 'lib/cocoapods-spm/resolver/result.rb', line 23

def initialize(options = {})
  ATTRS.each do |k, v|
    instance_variable_set("@#{k}", options[k] || v)
  end
end

Instance Method Details

#linker_flags_for(target) ⇒ Object



46
47
48
49
50
51
# File 'lib/cocoapods-spm/resolver/result.rb', line 46

def linker_flags_for(target)
  (
    spm_targets_for(target).flat_map(&:linker_flags) +
    spm_pkgs_for(target).flat_map(&:linker_flags)
  ).uniq
end

#spm_dependencies_for(target) ⇒ Object



33
34
35
# File 'lib/cocoapods-spm/resolver/result.rb', line 33

def spm_dependencies_for(target)
  @spm_dependencies_by_target[target.to_s].to_a
end

#spm_pkgs_for(target) ⇒ Object



29
30
31
# File 'lib/cocoapods-spm/resolver/result.rb', line 29

def spm_pkgs_for(target)
  spm_dependencies_for(target).map(&:pkg).uniq(&:name)
end

#spm_targets_for(target, exclude_default_xcode_linking: true) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/cocoapods-spm/resolver/result.rb', line 37

def spm_targets_for(target, exclude_default_xcode_linking: true)
  targets = spm_dependencies_for(target).flat_map do |d|
    project_pkgs.resolve_recursive_targets_of(d.pkg.name, d.product)
  end.uniq(&:name)
  return targets.reject(&:use_default_xcode_linking?) if exclude_default_xcode_linking

  targets
end