Sha256: 6b906e0926323765644f1a5214c60da62624c0f881e5b5a796b768295b96d5b6

Contents?: true

Size: 1.75 KB

Versions: 30

Compression:

Stored size: 1.75 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

    # Fetches the app platform from the given ipa file.
    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

    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
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
fastlane-2.1.1 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-1.0.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.1.0 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.0.5 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.0.4 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.0.3 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.0.2 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.0.1 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.59.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.58.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.57.2 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.57.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.57.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.56.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.55.1 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.55.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.54.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.53.0 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.52.3 lib/fastlane_core/ipa_file_analyser.rb
fastlane_core-0.52.2 lib/fastlane_core/ipa_file_analyser.rb