Sha256: 32905f805332a737a3a963158cfeb0fd5b98a1b0dd7fe27f1b353d55444fd139

Contents?: true

Size: 1.39 KB

Versions: 30

Compression:

Stored size: 1.39 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 = 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|
        zipfile.each do |file|
          next unless file.name.include? '.plist' and !['.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

      nil
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
fastlane_core-0.32.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.31.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.30.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.29.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.29.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.28.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.27.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.26.6 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.26.5 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.26.4 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.26.3 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.26.2 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.26.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.26.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.25.4 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.25.3 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.25.2 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.25.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.25.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.24.0 lib/fastlane_core/ipa_file_analyser.rb