Sha256: 55611a146e23989241665f259f935dc98925834967c556113f66583c2652c4c5

Contents?: true

Size: 1.32 KB

Versions: 23

Compression:

Stored size: 1.32 KB

Contents

require 'zip'
require 'plist'

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 = self.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 = self.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|
        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
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
fastlane_core-0.43.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.43.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.42.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.42.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.41.3 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.41.2 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.41.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.41.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.40.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.39.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.39.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.38.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.37.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.36.9 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.36.8 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.36.7 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.36.6 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.36.5 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.36.4 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.36.3 lib/fastlane_core/ipa_file_analyser.rb