class FastlaneCore::IpaUploadPackageBuilder

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

Constants

METADATA_FILE_NAME

Attributes

package_path[RW]

Public Instance Methods

generate(app_id: nil, ipa_path: nil, package_path: nil, platform: nil) click to toggle source
# 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)
  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
  }

  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, METADATA_FILE_NAME), xml)
  UI.success("Wrote XML data to '#{self.package_path}'") if FastlaneCore::Globals.verbose?

  return self.package_path
end
unique_ipa_path(ipa_path) click to toggle source
# File fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb, line 39
def unique_ipa_path(ipa_path)
  "#{Digest::SHA256.file(ipa_path).hexdigest}.ipa"
end

Private Instance Methods

copy_ipa(ipa_path) click to toggle source
# File fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb, line 45
def copy_ipa(ipa_path)
  ipa_file_name = unique_ipa_path(ipa_path)
  resulting_path = File.join(self.package_path, ipa_file_name)
  FileUtils.cp(ipa_path, resulting_path)

  return resulting_path
end