fix(fastlane): create editable App Store version before deliver

submit_review reached the deliver step but failed with "could not find
an editable version for 'IOS'". With skip_metadata + skip_screenshots,
deliver does not auto-create the "Prepare for Submission" entry on App
Store Connect, so submitting fails when the marketing version has not
been created yet.

Use Spaceship's ensure_version! to create or reuse the editable App
Store version for the build's marketing version, and pass app_version
to deliver so it targets the right entry.
This commit is contained in:
Mohamed Boudra
2026-05-08 21:42:24 +07:00
parent 39099a54b8
commit 4792cba794

View File

@@ -25,6 +25,7 @@ platform :ios do
app = Spaceship::ConnectAPI::App.find(APP_IDENTIFIER) app = Spaceship::ConnectAPI::App.find(APP_IDENTIFIER)
UI.user_error!("Could not find app #{APP_IDENTIFIER} on App Store Connect") if app.nil? UI.user_error!("Could not find app #{APP_IDENTIFIER} on App Store Connect") if app.nil?
valid_build = nil
deadline = Time.now + (30 * 60) deadline = Time.now + (30 * 60)
loop do loop do
builds = Spaceship::ConnectAPI::Build.all( builds = Spaceship::ConnectAPI::Build.all(
@@ -34,7 +35,10 @@ platform :ios do
build = builds.find { |b| b.pre_release_version&.platform == "IOS" } build = builds.find { |b| b.pre_release_version&.platform == "IOS" }
state = build&.processing_state state = build&.processing_state
UI.message("Build #{build_number} processing state: #{state || 'unknown'}") UI.message("Build #{build_number} processing state: #{state || 'unknown'}")
break if state == "VALID" if state == "VALID"
valid_build = build
break
end
if state == "INVALID" || state == "FAILED" if state == "INVALID" || state == "FAILED"
UI.user_error!("Build #{build_number} failed App Store processing (state: #{state}).") UI.user_error!("Build #{build_number} failed App Store processing (state: #{state}).")
end end
@@ -44,9 +48,18 @@ platform :ios do
sleep(30) sleep(30)
end end
app_version = valid_build.pre_release_version.version
UI.message("Submitting build #{build_number} as App Store version #{app_version} for review")
# Ensure an editable App Store version exists for this marketing version.
# deliver requires a "Prepare for Submission" version on App Store Connect
# and won't auto-create one when skip_metadata + skip_screenshots are set.
app.ensure_version!(app_version, platform: Spaceship::ConnectAPI::Platform::IOS)
deliver( deliver(
api_key: api_key, api_key: api_key,
app_identifier: APP_IDENTIFIER, app_identifier: APP_IDENTIFIER,
app_version: app_version,
build_number: build_number.to_s, build_number: build_number.to_s,
submit_for_review: true, submit_for_review: true,
automatic_release: true, automatic_release: true,