Class: FastlaneCore::IpaUploadPackageBuilder

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

Overview

Builds a package for the binary ready to be uploaded with the iTunes Transporter

Constant Summary collapse

METADATA_FILE_NAME =
"metadata.xml"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#package_pathObject

Returns the value of attribute package_path.



13
14
15
# File 'fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb', line 13

def package_path
  @package_path
end

Instance Method Details

#generate(app_id: nil, ipa_path: nil, package_path: nil, platform: nil, app_identifier: nil, short_version: nil, bundle_version: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb', line 15

def generate(app_id: nil, ipa_path: nil, package_path: nil, platform: nil, app_identifier: nil, short_version: nil, bundle_version: nil)
  unless Helper.is_mac?
    # .itmsp packages are not supported for ipa uploads starting Transporter 4.1, for non-macOS
    self.package_path = package_path
    copy_ipa(ipa_path)

    # copy any AppStoreInfo.plist file that's next to the ipa file
    app_store_info_path = File.join(File.dirname(ipa_path), "AppStoreInfo.plist")
    if File.exist?(app_store_info_path)
      FileUtils.cp(app_store_info_path, File.join(self.package_path, "AppStoreInfo.plist"))
    end

    return self.package_path
  end

  self.package_path = File.join(package_path, "#{app_id}-#{SecureRandom.uuid}.itmsp")
  FileUtils.rm_rf(self.package_path) if File.directory?(self.package_path)
  FileUtils.mkdir_p(self.package_path)

  ipa_path = copy_ipa(ipa_path)
  @data = {
    apple_id: app_id,
    file_size: File.size(ipa_path),
    ipa_path: File.basename(ipa_path), # this is only the base name as the ipa is inside the package
    md5: Digest::MD5.file(ipa_path).hexdigest,
    archive_type: "bundle",
    platform: (platform || "ios"), # pass "appletvos" for Apple TV's IPA
    app_identifier: app_identifier,
    short_version: short_version,
    bundle_version: bundle_version
  }

  xml_path = File.join(FastlaneCore::ROOT, "lib/assets/XMLTemplate.xml.erb")
  xml = ERB.new(File.read(xml_path)).result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system

  File.write(File.join(self.package_path, ), xml)
  UI.success("Wrote XML data to '#{self.package_path}'") if FastlaneCore::Globals.verbose?

  return self.package_path
end

#unique_ipa_path(ipa_path) ⇒ Object



56
57
58
# File 'fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb', line 56

def unique_ipa_path(ipa_path)
  "#{Digest::SHA256.file(ipa_path).hexdigest}.ipa"
end