lib/produce/itunes_connect.rb in produce-1.1.4 vs lib/produce/itunes_connect.rb in produce-1.2.0

- old
+ new

@@ -20,17 +20,32 @@ else UI.success "Creating new app '#{Produce.config[:app_name]}' on iTunes Connect" Produce.config[:bundle_identifier_suffix] = '' unless wildcard_bundle? - Spaceship::Tunes::Application.create!(name: Produce.config[:app_name], - primary_language: language, - version: Produce.config[:app_version] || "1.0", - sku: Produce.config[:sku].to_s, # might be an int - bundle_id: app_identifier, - bundle_id_suffix: Produce.config[:bundle_identifier_suffix], - company_name: Produce.config[:company_name]) + generated_app = Spaceship::Tunes::Application.create!(name: Produce.config[:app_name], + primary_language: language, + version: Produce.config[:app_version] || "1.0", + sku: Produce.config[:sku].to_s, # might be an int + bundle_id: app_identifier, + bundle_id_suffix: Produce.config[:bundle_identifier_suffix], + company_name: Produce.config[:company_name]) + + UI.crash!("Something went wrong when creating the new app on iTC") if generated_app["adamId"].to_s.empty? + application = fetch_application + counter = 0 + while application.nil? + counter += 1 + UI.crash!("Couldn't find newly created app on iTunes Connect - please check the website for more information") if counter == 60 + + # Since 2016-08-10 iTunes Connect takes some time to actually list the newly created application + # We have no choice but to poll to see if the newly created app is already available + UI.message("Waiting for the newly created application to be available on iTunes Connect...") + sleep 10 + application = fetch_application + end + UI.crash!("Something went wrong when creating the new app - it's not listed in the App's list") unless application UI.success "Successfully created new app '#{Produce.config[:app_name]}' on iTunes Connect with ID #{application.apple_id}" end