class DebugFile::Runner

Constants

ARCHIVE_PATH

Attributes

options[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/fastlane/plugin/debug_file/runner.rb, line 7
def initialize(options = {})
  @options = options
end

Public Instance Methods

latest_dsym(filter: :date) click to toggle source
# File lib/fastlane/plugin/debug_file/runner.rb, line 11
def latest_dsym(filter: :date)
  dsyms = list_dsym
  case filter
  when :version
    dsyms.max_by {|v| Gem::Version.new(v[:release_version])}
  else
    dsyms.max_by {|v| v[:created_at]}
  end
end
list_dsym() click to toggle source
# File lib/fastlane/plugin/debug_file/runner.rb, line 21
def list_dsym
  return [fetch_project_info(archive_path)] if project_archive_path? && !options[:scheme]

  search_dsym(archive_path, options[:scheme])
end

Private Instance Methods

archive_path() click to toggle source
# File lib/fastlane/plugin/debug_file/runner.rb, line 78
def archive_path
  @archive_path ||= File.expand_path(options.fetch(:archive_path, ARCHIVE_PATH))
end
fetch_project_info(path, scheme = nil) click to toggle source
# File lib/fastlane/plugin/debug_file/runner.rb, line 42
def fetch_project_info(path, scheme = nil)
  info = Fastlane::Helper::DebugFileHelper.xcarchive_metadata(File.join(path, 'Info.plist'))
  name = Fastlane::Helper::DebugFileHelper.fetch_key(info, 'Name')
  return unless scheme.to_s.empty? || scheme == name

  release_version = Fastlane::Helper::DebugFileHelper.fetch_key(info, 'ApplicationProperties', 'CFBundleShortVersionString')
  build = Fastlane::Helper::DebugFileHelper.fetch_key(info, 'ApplicationProperties', 'CFBundleVersion')
  dsym_path = File.join(path, 'dSYMs', "#{name}.app.dSYM")
  dsym_binray_path = Dir.glob(File.join(dsym_path, '**', '*', name)).first
  created_at = Fastlane::Helper::DebugFileHelper.fetch_key(info, 'CreationDate')

  machos = []
  Fastlane::Helper::DebugFileHelper.macho_metadata(dsym_binray_path).each do |macho|
    machos << {
      arch: macho.cpusubtype,
      uuid: macho[:LC_UUID][0].uuid_string
    }
  end

  {
    root_path: File.basename(File.dirname(path)),
    dsym_path: dsym_path,
    machos: machos,
    info: info,
    name: name,
    release_version: release_version,
    build: build,
    created_at: created_at,
  }
end
project_archive_path?() click to toggle source
# File lib/fastlane/plugin/debug_file/runner.rb, line 73
def project_archive_path?
  File.file?(File.join(archive_path, 'Info.plist')) &&
    Dir.exist?(File.join(archive_path, 'dSYMs'))
end
search_dsym(path, scheme = nil) { |item| ... } click to toggle source
# File lib/fastlane/plugin/debug_file/runner.rb, line 29
def search_dsym(path, scheme = nil)
  project_path = File.join(path, '**', '*.xcarchive')
  obj = []
  Dir.glob(project_path) do |path|
    next unless item = fetch_project_info(path, scheme)

    yield item if block_given?
    obj << item
  end

  obj
end