class FastlaneCore::IpaFileAnalyser

Public Class Methods

fetch_app_identifier(path) click to toggle source

Fetches the app identifier (e.g. com.facebook.Facebook) from the given ipa file.

# File lib/fastlane_core/ipa_file_analyser.rb, line 7
def self.fetch_app_identifier(path)
  plist = self.fetch_info_plist_file(path)
  return plist['CFBundleIdentifier'] if plist
  return nil
end
fetch_app_platform(path) click to toggle source

Fetches the app platform from the given ipa file.

# File lib/fastlane_core/ipa_file_analyser.rb, line 21
def self.fetch_app_platform(path)
  plist = self.fetch_info_plist_file(path)
  platform = "ios"
  platform = plist['DTPlatformName'] if plist
  platform = "ios" if platform == "iphoneos" # via https://github.com/fastlane/spaceship/issues/247
  return platform
end
fetch_app_version(path) click to toggle source

Fetches the app version from the given ipa file.

# File lib/fastlane_core/ipa_file_analyser.rb, line 14
def self.fetch_app_version(path)
  plist = self.fetch_info_plist_file(path)
  return plist['CFBundleShortVersionString'] if plist
  return nil
end
fetch_info_plist_file(path) click to toggle source
# File lib/fastlane_core/ipa_file_analyser.rb, line 29
def self.fetch_info_plist_file(path)
  UI.user_error!("Could not find file at path '#{path}'") unless File.exist?(path)
  Zip::File.open(path) do |zipfile|
    file = zipfile.glob('**/Payload/*.app/Info.plist').first
    return nil unless file

    # We can not be completely sure, that's the correct plist file, so we have to try
    begin
      # The XML file has to be properly unpacked first
      tmp_path = "/tmp/deploytmp.plist"
      File.write(tmp_path, zipfile.read(file))
      system("plutil -convert xml1 #{tmp_path}")
      result = Plist.parse_xml(tmp_path)
      File.delete(tmp_path)

      if result['CFBundleIdentifier'] or result['CFBundleVersion']
        return result
      end
    rescue
      # We don't really care, look for another XML file
    end
  end

  nil
end