class Fastlane::BinaryChecker

Public Class Methods

new(file_path) click to toggle source
# File lib/fastlane/plugin/checkbuild/actions/checkbuild_action.rb, line 6
def initialize(file_path)
  UI.verbose("Initialized new checker")
  @file_path = file_path
end

Public Instance Methods

check_architectures(required_archs) click to toggle source
# File lib/fastlane/plugin/checkbuild/actions/checkbuild_action.rb, line 11
def check_architectures(required_archs)
  UI.verbose("Checking architectures...")
  lipo = %x( command -v lipo ).strip
  if lipo != "" then
    command = lipo + " -info " + @file_path
    result = `#{command}`

    required_archs.chunk { |arch|
      result[arch] != nil
    }.each { |found, arch|
      if found == false then
        UI.error("Non fat file, missing #{arch}")
        return
      elsif found == true then
        UI.success("Found all necessary architectures! #{arch}")
        return
      end
    }
  else
    UI.error("Command lipo not found!")
  end
end
check_bitcode_availability() click to toggle source
# File lib/fastlane/plugin/checkbuild/actions/checkbuild_action.rb, line 85
  def check_bitcode_availability
    UI.verbose("Check if bitcode is available")
    otool = %x( command -v otool ).strip
    if otool != "" then
      command = otool + " -arch arm64 -l " + @file_path
      result = `#{command}`

      contains_llvm = false
      if result.include? "__LLVM" then
        contains_llvm = true
      end

      contains_filesize = false
      if result.include? "filesize"
      # TODO
      contains_filesize = true
    end

    if contains_llvm && contains_filesize then
      UI.message("Bitcode active!")
    else
      UI.message("Bitcode inactive!")
    end
  else
    UI.error("Command otool not found!")
  end
end
check_coverage_symbols() click to toggle source
# File lib/fastlane/plugin/checkbuild/actions/checkbuild_action.rb, line 34
def check_coverage_symbols
  UI.verbose("Check for coverage symbols...")
  otool = %x( command -v otool ).strip
  if otool != "" then
    command = otool + " -l -arch all " + @file_path
    result = `#{command}`

    if result.include? "__llvm_cov" then
      UI.error("File contains coverage symbols!")
    else
      UI.success("File does not contain any coverage symbols!")
    end
  else
    UI.error("Command otool not found!")
  end
end
check_debug_symbols() click to toggle source
# File lib/fastlane/plugin/checkbuild/actions/checkbuild_action.rb, line 130
def check_debug_symbols
  UI.verbose("Check for debug symbols")
  nm = %x( command -v nm ).strip
  if nm != "" then
    command1 = nm + " " + @file_path
    command2 = nm + " -a " + @file_path
    slimDump = `#{command1}`
    fatDump = `#{command2}`
    # TODO
  end
end
check_encryption() click to toggle source
# File lib/fastlane/plugin/checkbuild/actions/checkbuild_action.rb, line 68
def check_encryption
  UI.verbose("Check encryption info...")
  otool = %x( command -v otool ).strip
  if otool != "" then
    command = otool + " -l " + @file_path
    result = `#{command}`

    if result.include? "LC_ENCRYPTION_INFO" then
      UI.message("File contains encryption info!")
    else
      UI.message("File does not contain any encryption info!")
    end
  else
    UI.error("Command otool not found!")
  end
end
check_for_assertion() click to toggle source
# File lib/fastlane/plugin/checkbuild/actions/checkbuild_action.rb, line 113
def check_for_assertion
  UI.verbose("Check for assertions...")
  nm = %x( command -v nm ).strip
  if nm != "" then
    command = nm + " " + @file_path
    result = `#{command}`

    if result.include? "NSAssertionHandler" then
      UI.error("File contains assertions!")
    else
      UI.success("File does not contain any assertions!")
    end
  else
    UI.error("Command nm not found!")
  end
end
check_for_flagged_tests() click to toggle source
# File lib/fastlane/plugin/checkbuild/actions/checkbuild_action.rb, line 142
def check_for_flagged_tests
  UI.verbose("Check for flagged tests")

end
check_profiling_data() click to toggle source
# File lib/fastlane/plugin/checkbuild/actions/checkbuild_action.rb, line 51
def check_profiling_data
  UI.verbose("Check profiling info...")
  otool = %x( command -v otool ).strip
  if otool != "" then
    command = otool + " -l -arch all " + @file_path
    result = `#{command}`

    if result.include? "__llvm_" then
      UI.error("File contains profiling data!")
    else
      UI.success("File does not contain any profiling data!")
    end
  else
    UI.error("Command otool not found!")
  end
end