class PodAlexandria::Dependency

Attributes

flag[R]
module_name[R]

Public Class Methods

new(value) click to toggle source
# File lib/cocoapods-alexandria/xcodegen/dependency.rb, line 6
def initialize(value)
  @flag = value.start_with?('-wf') ? 'wf' : value[1]
  @module_name = value.delete_prefix('-l').delete_prefix('-f').delete_prefix('-wf')
end

Public Instance Methods

xcodegen_info(allow_embed) click to toggle source
# File lib/cocoapods-alexandria/xcodegen/dependency.rb, line 11
def xcodegen_info(allow_embed)
  if exists?
    {
      'framework' => path,
      'embed' => is_dynamic? && allow_embed,
      'weak' => is_weak?
    }
  else
    {
      'sdk' => sdk,
      'weak' => is_weak?
    }
  end
end

Private Instance Methods

binary_name() click to toggle source
# File lib/cocoapods-alexandria/xcodegen/dependency.rb, line 63
def binary_name
  if is_library?
    "lib#{module_name}.a"
  else
    module_name
  end
end
exists?() click to toggle source
# File lib/cocoapods-alexandria/xcodegen/dependency.rb, line 41
def exists?
  path != nil
end
is_dynamic?() click to toggle source
# File lib/cocoapods-alexandria/xcodegen/dependency.rb, line 45
def is_dynamic?
  if path.end_with? 'xcframework'
    any_arch = Dir["#{path}/*/*.framework"].first
    binary = "#{any_arch}/#{module_name}"
  else
    binary = "#{path}/#{module_name}"
  end
  !%x(file #{binary} | grep dynamic).to_s.strip.empty?
end
is_library?() click to toggle source
# File lib/cocoapods-alexandria/xcodegen/dependency.rb, line 55
def is_library?
  flag == 'l'
end
is_weak?() click to toggle source
# File lib/cocoapods-alexandria/xcodegen/dependency.rb, line 59
def is_weak?
  flag == 'wf'
end
path() click to toggle source
# File lib/cocoapods-alexandria/xcodegen/dependency.rb, line 28
def path
  binary = Dir["Rome/*.{framework,xcframework}/**/#{binary_name}"].first
  binary&.split(File::SEPARATOR)&.first(2)&.join(File::SEPARATOR)
end
sdk() click to toggle source
# File lib/cocoapods-alexandria/xcodegen/dependency.rb, line 33
def sdk
  if is_library?
    "lib#{module_name}.tbd"
  else
    "#{module_name}.framework"
  end
end