Sha256: b3562fa7a8f4695ec1233a4eb5d1afc6e06205d74b6eabc456165c8e4f47cda8

Contents?: true

Size: 1.8 KB

Versions: 322

Compression:

Stored size: 1.8 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, "rb") 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.open(tmp_path, 'wb') do |output|
            output.write zipfile.read(file)
          end
          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

322 entries across 322 versions & 1 rubygems

Version Path
fastlane-2.65.0.beta.20171113010004 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.65.0.beta.20171112010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.65.0.beta.20171111010004 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.65.0.beta.20171110010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.65.0.beta.20171109010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.65.0.beta.20171108010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.65.0.beta.20171107010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.64.0 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.64.0.beta.20171106010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.64.0.beta.20171105010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.64.0.beta.20171104010004 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.64.0.beta.20171103010004 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.64.0.beta.20171102010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.64.0.beta.20171101010004 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.63.0 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.63.0.beta.20171031010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.63.0.beta.20171030010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.63.0.beta.20171029010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.63.0.beta.20171028010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane-2.63.0.beta.20171027010003 fastlane_core/lib/fastlane_core/ipa_file_analyser.rb