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/dependency.rb,
lib/cocoapods-spm/swift/package/description.rb

Direct Known Subclasses

Pod::SPM::MacroMetadata

Defined Under Namespace

Classes: Dependency, Product, Resources, Target

Instance Attribute Summary

Attributes inherited from PackageDescriptionBaseObject

#parent, #raw

Class Method Summary collapse

Instance Method Summary collapse

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

#local_macro_pod?, #local_macro_pod_dir, #macro_pods, #spm_config

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

#pod_config

Methods included from Pod::SPM::PathMixn

#prepare_dir

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

Class Method Details

.from_dir(dir) ⇒ Object



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

def self.from_dir(dir)
  raw = `swift package dump-package --package-path #{dir.shellescape}`
  from_s(raw)
end

Instance Method Details

#artifacts_dirObject



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

def artifacts_dir
  spm_config.pkg_artifacts_dir / slug
end

#checkouts_dirObject



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

def checkouts_dir
  src_dir.parent
end

#dependenciesObject



35
36
37
# File 'lib/cocoapods-spm/swift/package/description.rb', line 35

def dependencies
  @dependencies ||= convert_field("dependencies", Dependency)
end

#macro_impl_nameObject



58
59
60
# File 'lib/cocoapods-spm/swift/package/description.rb', line 58

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

#productsObject



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

def products
  @products ||= convert_field("products", Product)
end

#slugObject



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

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

#src_dirObject



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

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

#targetsObject



39
40
41
# File 'lib/cocoapods-spm/swift/package/description.rb', line 39

def targets
  @targets ||= convert_field("targets", Target)
end

#targets_of_product(name) ⇒ Object



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

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)


62
63
64
65
66
67
# File 'lib/cocoapods-spm/swift/package/description.rb', line 62

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