Sha256: a04387cd6abeb6f0f55aeea63d0fd110066ea81b11e2723edfb075384d7bca07

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

require 'zip'

module FastlaneCore
  class IpaFileAnalyser

    # Fetches the app identifier (e.g. com.facebook.Facebook) from the given ipa file.
    def self.fetch_app_identifier(path)
      plist = IpaFileAnalyser.fetch_info_plist_file(path)
      return plist['CFBundleIdentifier'] if plist
      return nil
    end

    # Fetches the app version from the given ipa file.
    def self.fetch_app_version(path)
      plist = IpaFileAnalyser.fetch_info_plist_file(path)
      return plist['CFBundleShortVersionString'] if plist
      return nil
    end

    def self.fetch_info_plist_file(path)
      Zip::File.open(path) do |zipfile|
        zipfile.each do |file|
          if file.name.include?'.plist' and not ['.bundle', '.framework'].any? { |a| file.name.include?a }
            # 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
        end
      end

      nil
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fastlane_core-0.15.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.15.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.14.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.13.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.13.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.12.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.11.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.11.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.10.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.10.0 lib/fastlane_core/ipa_file_analyser.rb