Class: Pod::Swift::ProjectPackages
- Inherits:
-
Object
- Object
- Pod::Swift::ProjectPackages
- Defined in:
- lib/cocoapods-spm/swift/package/project_packages.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ProjectPackages
constructor
A new instance of ProjectPackages.
- #pkg_desc_of(name) ⇒ Object
- #resolve_recursive_targets_of(pkg_name, product_name) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ProjectPackages
Returns a new instance of ProjectPackages.
6 7 8 9 10 11 12 13 |
# File 'lib/cocoapods-spm/swift/package/project_packages.rb', line 6 def initialize( = {}) @src_dir = [:src_dir] raise Informative, "src_dir must not be nil" if @src_dir.nil? @json_dir = [:write_json_to_dir] @pkg_desc_cache = {} load end |
Instance Method Details
#pkg_desc_of(name) ⇒ Object
31 32 33 34 35 |
# File 'lib/cocoapods-spm/swift/package/project_packages.rb', line 31 def pkg_desc_of(name) return @pkg_desc_cache[name] if @pkg_desc_cache.key?(name) raise Informative, "Package description of `#{name}` does not exist!" end |
#resolve_recursive_targets_of(pkg_name, product_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cocoapods-spm/swift/package/project_packages.rb', line 15 def resolve_recursive_targets_of(pkg_name, product_name) @recursive_targets_cache ||= {} return @recursive_targets_cache[product_name] if @recursive_targets_cache.key(product_name) res = [] to_visit = pkg_desc_of(pkg_name).targets_of_product(product_name) until to_visit.empty? target = to_visit.pop res << target # Exclude macros as they wont be linked to the project's binary # https://github.com/trinhngocthuyen/cocoapods-spm/issues/107 to_visit += target.resolve_dependencies(@pkg_desc_cache).reject(&:macro?) end @recursive_targets_cache[product_name] = res.uniq(&:name) end |