Class: FastlaneCore::PkgUploadPackageBuilder

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

Overview

Builds a package for the pkg 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.



12
13
14
# File 'fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb', line 12

def package_path
  @package_path
end

Instance Method Details

#generate(app_id: nil, pkg_path: nil, package_path: nil, platform: "osx") ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb', line 14

def generate(app_id: nil, pkg_path: nil, package_path: nil, platform: "osx")
  self.package_path = File.join(package_path, "#{app_id}.itmsp")
  FileUtils.rm_rf(self.package_path) if File.directory?(self.package_path)
  FileUtils.mkdir_p(self.package_path)

  pkg_path = copy_pkg(pkg_path)
  @data = {
    apple_id: app_id,
    file_size: File.size(pkg_path),
    ipa_path: File.basename(pkg_path), # this is only the base name as the ipa is inside the package
    md5: Digest::MD5.hexdigest(File.read(pkg_path)),
    archive_type: 'product-archive',
    platform: platform
  }

  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?

  package_path
end