Class: Pod::Swift::PackageDescription

Inherits:
PackageDescriptionBaseObject show all
Includes:
Pod::SPM::Config::Mixin
Defined in:
lib/cocoapods-spm/swift/package/target.rb,
lib/cocoapods-spm/swift/package/product.rb,
lib/cocoapods-spm/swift/package/resources.rb,
lib/cocoapods-spm/swift/package/description.rb

Direct Known Subclasses

Pod::SPM::MacroMetadata

Defined Under Namespace

Classes: Product, Resources, Target

Instance Attribute Summary

Attributes inherited from PackageDescriptionBaseObject

#parent, #raw

Instance Method Summary collapse

Methods included from Pod::SPM::Config::SPMConfigMixin

#macro_pods, #spm_config

Methods included from Pod::SPM::Config::PodConfigMixin

#pod_config

Methods included from Pod::SPM::Config::ProjectConfigMixin

#project_config

Methods inherited from PackageDescriptionBaseObject

#[], #dup_with_attrs, from_file, from_s, #initialize, #inspect, #name, #pkg_name, #root

Constructor Details

This class inherits a constructor from Pod::Swift::PackageDescriptionBaseObject

Instance Method Details

#artifacts_dirObject



17
18
19
# File 'lib/cocoapods-spm/swift/package/description.rb', line 17

def artifacts_dir
  spm_config.pkg_artifacts_dir / slug
end

#macro_impl_nameObject



44
45
46
# File 'lib/cocoapods-spm/swift/package/description.rb', line 44

def macro_impl_name
  targets.find(&:macro?)&.name
end

#productsObject



29
30
31
# File 'lib/cocoapods-spm/swift/package/description.rb', line 29

def products
  @products ||= raw.fetch("products", []).flat_map { |h| Product.new(h, parent: nil) }
end

#slugObject



21
22
23
# File 'lib/cocoapods-spm/swift/package/description.rb', line 21

def slug
  src_dir.nil? ? name : src_dir.basename.to_s
end

#src_dirObject



10
11
12
13
14
15
# File 'lib/cocoapods-spm/swift/package/description.rb', line 10

def src_dir
  @src_dir ||= begin
    path = raw.fetch("packageKind", {}).fetch("root", [])[0]
    Pathname.new(path) unless path.nil?
  end
end

#targetsObject



25
26
27
# File 'lib/cocoapods-spm/swift/package/description.rb', line 25

def targets
  @targets ||= raw.fetch("targets", []).flat_map { |h| Target.new(h, parent: self) }
end

#targets_of_product(name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/cocoapods-spm/swift/package/description.rb', line 33

def targets_of_product(name)
  matched_products = products.select { |p| p.name == name }
  dynamic = matched_products.any?(&:dynamic?)
  matched_products
    .flat_map do |p|
      targets.select { |t| p.target_names.include?(t.name) }.map do |t|
        t.dup_with_attrs(dynamic: dynamic, product_name: name)
      end
    end
end

#use_default_xcode_linking?Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
# File 'lib/cocoapods-spm/swift/package/description.rb', line 48

def use_default_xcode_linking?
  return @use_default_xcode_linking unless @use_default_xcode_linking.nil?

  pkg = pod_config.podfile.spm_pkgs.find { |t| t.name == name }
  @use_default_xcode_linking = pkg&.use_default_xcode_linking?
end