Class: FastlaneCore::IpaFileAnalyser

Inherits:
Object
  • Object
show all
Defined in:
fastlane_core/lib/fastlane_core/ipa_file_analyser.rb

Class Method Summary collapse

Class Method Details

.fetch_app_build(path) ⇒ Object

Fetches the app build number from the given ipa file.



23
24
25
26
27
# File 'fastlane_core/lib/fastlane_core/ipa_file_analyser.rb', line 23

def self.fetch_app_build(path)
  plist = self.fetch_info_plist_file(path)
  return plist['CFBundleVersion'] if plist
  return nil
end

.fetch_app_identifier(path) ⇒ Object

Fetches the app identifier (e.g. com.facebook.Facebook) from the given ipa file.



9
10
11
12
13
# File 'fastlane_core/lib/fastlane_core/ipa_file_analyser.rb', line 9

def self.fetch_app_identifier(path)
  plist = self.fetch_info_plist_file(path)
  return plist['CFBundleIdentifier'] if plist
  return nil
end

.fetch_app_platform(path) ⇒ Object

Fetches the app platform from the given ipa file.



30
31
32
33
34
35
36
# File 'fastlane_core/lib/fastlane_core/ipa_file_analyser.rb', line 30

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/fastlane/issues/3484
  return platform
end

.fetch_app_version(path) ⇒ Object

Fetches the app version from the given ipa file.



16
17
18
19
20
# File 'fastlane_core/lib/fastlane_core/ipa_file_analyser.rb', line 16

def self.fetch_app_version(path)
  plist = self.fetch_info_plist_file(path)
  return plist['CFBundleShortVersionString'] if plist
  return nil
end

.fetch_info_plist_file(path) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'fastlane_core/lib/fastlane_core/ipa_file_analyser.rb', line 38

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
      result = CFPropertyList.native_types(CFPropertyList::List.new(file: tmp_path).value)

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

  return nil
end