Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deliver cannot upload a build with Individual API Key #22115

Closed
4 tasks done
manicmaniac opened this issue Jun 28, 2024 · 0 comments · Fixed by #22128
Closed
4 tasks done

Deliver cannot upload a build with Individual API Key #22115

manicmaniac opened this issue Jun 28, 2024 · 0 comments · Fixed by #22128

Comments

@manicmaniac
Copy link
Contributor

manicmaniac commented Jun 28, 2024

New Issue Checklist

Issue Description

fastlane now supports Individual API Key with #21959. However, when I run deliver with an Individual API Key, the following error occurs.

[19:13:05]: [altool]     NSLocalizedDescription = "Unable to upload archive.";
[19:13:05]: [altool]     NSLocalizedFailureReason = "--upload-app is missing one or more required options: --type.";

At the time error occured, deliver was calling the command like the following.

/Applications/Xcode_15.2.app/Contents/Developer/usr/bin/altool --upload-app --apiKey ************ --apiIssuer -t ios -f /var/folders/j0/pkvk4p915q165qrhnwn2wq5w42tbf8/T/dd8275d0-eda1-4696-915f-96fdfe066594.ipa
 -k 100000

This command is invalid. --apiIssuer needs an argument but it is not passed. Instead, the next option flag -t is considered as the argument of --apiIssuer, so altool complains that there's no --type option.

Deliver is internally divided into 2 steps, a metadata upload step and a build upload phase.
Individual API Key works fine in the former, but fails in the latter.
This is because the altool used by deliver has not yet supported Individual API Keys.
Individual API Keys do not have an issuer ID, but altool requires you to enter an issuer ID.

As a workaround, you can force the deliverer to use an app-specific password instead of an API key when using altool by writing a snippet like the following in your Fastfile.

⚠️ This monkey patch is too naive. I don't recommend applying it unless you know what you do.

require "deliver"

# Monkey patch for https://github.com/fastlane/fastlane/blob/2.221.1/deliver/lib/deliver/runner.rb#L270
class ::Deliver::Runner
  # Force deliver use app-specific password instead of API key
  def transporter_for_selected_team
    tunes_client = Spaceship::ConnectAPI.client.tunes_client

    generic_transporter = FastlaneCore::ItunesTransporter.new(options[:username], nil, false, options[:itc_provider], altool_compatible_command: true)
    return generic_transporter unless options[:itc_provider].nil? && tunes_client.teams.count > 1

    begin
      team = tunes_client.teams.find { |t| t['providerId'].to_s == tunes_client.team_id }
      name = team['name']
      provider_id = generic_transporter.provider_ids[name]
      UI.verbose("Inferred provider id #{provider_id} for team #{name}.")
      return FastlaneCore::ItunesTransporter.new(options[:username], nil, false, provider_id, altool_compatible_command: true, api_key: api_key)
    rescue => ex
      UI.verbose("Couldn't infer a provider short name for team with id #{tunes_client.team_id} automatically: #{ex}. Proceeding without provider short name.")
      return generic_transporter
    end
  end
end

I confirmed it worked well.

Command executed
$ fastlane run deliver
...
[19:13:05]: [altool]     NSLocalizedDescription = "Unable to upload archive.";
[19:13:05]: [altool]     NSLocalizedFailureReason = "--upload-app is missing one or more required options: --type.";
...

Environment

  • fastlane 2.221.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant