class FastlaneCore::ItunesTransporter
Constants
- TWO_STEP_HOST_PREFIX
Public Class Methods
This will be called from the Deliverfile, and disables the logging of the transporter output
# File lib/fastlane_core/itunes_transporter.rb, line 271 def self.hide_transporter_output @hide_transporter_output = !$verbose end
# File lib/fastlane_core/itunes_transporter.rb, line 275 def self.hide_transporter_output? @hide_transporter_output end
Returns a new instance of the iTunesTransporter. If no username or password given, it will be taken from the #{CredentialsManager::AccountManager} @param use_shell_script if true, forces use of the iTMSTransporter shell script.
if false, allows a direct call to the iTMSTransporter Java app (preferred). see: https://github.com/fastlane/fastlane/pull/4003
@param provider_short_name The provider short name to be given to the iTMSTransporter to identify the
correct team for this work. The provider short name is usually your Developer Portal team ID, but in certain cases it is different! see: https://github.com/fastlane/fastlane/issues/1524#issuecomment-196370628 for more information about how to use the iTMSTransporter to list your provider short names
# File lib/fastlane_core/itunes_transporter.rb, line 291 def initialize(user = nil, password = nil, use_shell_script = false, provider_short_name = nil) # Xcode 6.x doesn't have the same iTMSTransporter Java setup as later Xcode versions, so # we can't default to using the better direct Java invocation strategy for those versions. use_shell_script ||= Helper.is_mac? && Helper.xcode_version.start_with?('6.') use_shell_script ||= Feature.enabled?('FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT') # First, see if we have an application specific password data = CredentialsManager::AccountManager.new(user: user, prefix: TWO_STEP_HOST_PREFIX) @user = data.user @password ||= data.password(ask_if_missing: false) if @password.to_s.length == 0 # No specific password found, just using the iTC/Dev Portal one # default to the given password here data = CredentialsManager::AccountManager.new(user: user, password: password) @user = data.user @password ||= data.password end @transporter_executor = use_shell_script ? ShellScriptTransporterExecutor.new : JavaTransporterExecutor.new @provider_short_name = provider_short_name end
Public Instance Methods
Downloads the latest version of the app metadata package from iTC. @param app_id [Integer] The unique App ID @param dir [String] the path in which the package file should be stored @return (Bool) True if everything worked fine @raise [Deliver::TransporterTransferError] when something went wrong
when transfering
# File lib/fastlane_core/itunes_transporter.rb, line 321 def download(app_id, dir = nil) dir ||= "/tmp" UI.message("Going to download app metadata from iTunes Connect") command = @transporter_executor.build_download_command(@user, @password, app_id, dir, @provider_short_name) UI.verbose(@transporter_executor.build_download_command(@user, 'YourPassword', app_id, dir, @provider_short_name)) begin result = @transporter_executor.execute(command, ItunesTransporter.hide_transporter_output?) rescue TransporterRequiresApplicationSpecificPasswordError => ex handle_two_step_failure(ex) return download(app_id, dir) end return result if Helper.is_test? itmsp_path = File.join(dir, "#{app_id}.itmsp") successful = result && File.directory?(itmsp_path) if successful UI.success("✅ Successfully downloaded the latest package from iTunes Connect to #{itmsp_path}") else handle_error(@password) end successful end
Uploads the modified package back to iTunes Connect @param app_id [Integer] The unique App ID @param dir [String] the path in which the package file is located @return (Bool) True if everything worked fine @raise [Deliver::TransporterTransferError] when something went wrong
when transfering
# File lib/fastlane_core/itunes_transporter.rb, line 355 def upload(app_id, dir) actual_dir = File.join(dir, "#{app_id}.itmsp") UI.message("Going to upload updated app to iTunes Connect") UI.success("This might take a few minutes. Please don't interrupt the script.") command = @transporter_executor.build_upload_command(@user, @password, actual_dir, @provider_short_name) UI.verbose(@transporter_executor.build_upload_command(@user, 'YourPassword', actual_dir, @provider_short_name)) begin result = @transporter_executor.execute(command, ItunesTransporter.hide_transporter_output?) rescue TransporterRequiresApplicationSpecificPasswordError => ex handle_two_step_failure(ex) return upload(app_id, dir) end if result UI.success("-" * 102) UI.success("Successfully uploaded package to iTunes Connect. It might take a few minutes until it's visible online.") UI.success("-" * 102) FileUtils.rm_rf(actual_dir) unless Helper.is_test? # we don't need the package any more, since the upload was successful else handle_error(@password) end result end
Private Instance Methods
# File lib/fastlane_core/itunes_transporter.rb, line 405 def handle_error(password) @transporter_executor.handle_error(password) end
Tells the user how to get an application specific password
# File lib/fastlane_core/itunes_transporter.rb, line 387 def handle_two_step_failure(ex) a = CredentialsManager::AccountManager.new(user: @user, prefix: TWO_STEP_HOST_PREFIX) if a.password(ask_if_missing: false).to_s.length > 0 # user already entered one.. delete the old one UI.error("Application specific password seems wrong") UI.error("Please make sure to follow the instructions") a.remove_from_keychain end UI.error("Your account has 2 step verification enabled") UI.error("Please go to https://appleid.apple.com/account/manage") UI.error("and generate an application specific password for") UI.error("the iTunes Transporter, which is used to upload builds") @password = a.password # to ask the user for the missing value return true end