Class: Deliver::IpaUploader

Inherits:
AppMetadata show all
Defined in:
lib/deliver/ipa_uploader.rb

Overview

This class takes care of preparing and uploading the given ipa file Metadata + IPA file can not be handled in one file

Constant Summary

Constants inherited from AppMetadata

AppMetadata::INVALID_LANGUAGE_ERROR, AppMetadata::ITUNES_NAMESPACE

Instance Attribute Summary collapse

Attributes inherited from AppMetadata

#information

Uploading the ipa file collapse

Instance Method Summary collapse

Methods inherited from AppMetadata

#add_new_locale, #add_screenshot, #clear_all_screenshots, #fetch_value, #set_all_screenshots, #set_all_screenshots_from_path, #set_screenshots_for_each_language, #update_changelog, #update_description, #update_keywords, #update_marketing_url, #update_price_tier, #update_privacy_url, #update_support_url, #update_title, #verify_version

Constructor Details

#initialize(app, dir, ipa_path, publish_strategy) ⇒ IpaUploader

Create a new uploader for one ipa file. This will only upload the ipa and no other app metadata. If it’s a production build it will be released into production. Otherwise no action.

Parameters:

  • app (Deliver::App)

    The app for which the ipa should be uploaded for

  • dir (String)

    The path to where we can store (copy) the ipa file. Usually /tmp/

  • ipa_path (String)

    The path to the IPA file which should be uploaded

  • publish_strategy (Int)

    If it’s a beta build, it will be released to the testers.

Raises:

  • (IpaUploaderError)

    Is thrown when the ipa file was not found or is not valid



26
27
28
29
30
31
32
33
34
35
# File 'lib/deliver/ipa_uploader.rb', line 26

def initialize(app, dir, ipa_path, publish_strategy)
  ipa_path.strip! # remove unused white spaces
  raise IpaUploaderError.new("IPA on path '#{ipa_path}' not found") unless File.exists?(ipa_path)
  raise IpaUploaderError.new("IPA on path '#{ipa_path}' is not a valid IPA file") unless ipa_path.include?".ipa"

  super(app, dir, false)

  @ipa_file = Deliver::MetadataItem.new(ipa_path)
  @publish_strategy = publish_strategy
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



15
16
17
# File 'lib/deliver/ipa_uploader.rb', line 15

def app
  @app
end

#publish_strategyObject

Returns the value of attribute publish_strategy.



16
17
18
# File 'lib/deliver/ipa_uploader.rb', line 16

def publish_strategy
  @publish_strategy
end

Instance Method Details

#fetch_app_identifierObject

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



38
39
40
# File 'lib/deliver/ipa_uploader.rb', line 38

def fetch_app_identifier
  return IpaFileAnalyser.fetch_app_identifier(@ipa_file.path)
end

#fetch_app_versionObject

Fetches the app version from the given ipa file.



43
44
45
# File 'lib/deliver/ipa_uploader.rb', line 43

def fetch_app_version
  return IpaFileAnalyser.fetch_app_version(@ipa_file.path)
end

#upload!(submit_information = nil) ⇒ Object

Actually upload the ipa file to Apple

Parameters:

  • submit_information (Hash) (defaults to: nil)

    A hash containing submit information (export, content rights)



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/deliver/ipa_uploader.rb', line 54

def upload!(submit_information = nil)
  Helper.log.info "Uploading ipa file to iTunesConnect"
  build_document

  # Write the current XML state to disk
  folder_name = "#{@app.apple_id}.itmsp"
  path = "#{@metadata_dir}/#{folder_name}/"
  FileUtils.mkdir_p path

  File.write("#{path}/#{METADATA_FILE_NAME}", @data.to_xml)

  @ipa_file.store_file_inside_package(path)

  is_okay = true
  begin
    is_okay = transporter.upload(@app, @metadata_dir)
  rescue => ex
    Helper.log.debug ex
    is_okay = ex.to_s.include?"ready exists a binary upload with build" # this just means, the ipa is already online
  end

  if is_okay
    unless Helper.is_test?
      return publish_on_itunes_connect(submit_information)
    end
  end

  return is_okay
end