Sha256: 23e9ac6d850c09b3dc1c01d6eb59fab84ff172531cd24079934e88ab0cf62e17

Contents?: true

Size: 1.75 KB

Versions: 53

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

        # Creates a temporary directory with a unique name tagged with 'fastlane'
        # The directory is deleted automatically at the end of the block
        Dir.mktmpdir("fastlane") do |tmp|
          # The XML file has to be properly unpacked first
          tmp_path = File.join(tmp, "Info.plist")
          File.write(tmp_path, zipfile.read(file))
          system("plutil -convert xml1 #{tmp_path}")
          result = Plist.parse_xml(tmp_path)

          if result['CFBundleIdentifier'] or result['CFBundleVersion']
            return result
          end
        end
      end

      return nil
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
fastlane-2.19.3 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.20.0.beta.20170307010029 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.2 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.20.0.beta.20170306010752 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.20.0.beta.20170305010057 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.20.0.beta.20170304010023 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.20.0.beta.20170303010054 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.20.0.beta.20170302010029 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.1 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.0 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.0.beta.20170301010932 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.0.beta.20170228010016 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.0.beta.20170227010016 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.0.beta.20170226010028 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.0.beta.20170225010031 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.0.beta.20170224010025 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.18.3 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.0.beta.20170223010028 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.18.2 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.19.0.beta.20170222010016 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb