read

Fastlane was great since the early days of iPhone development, but they are on the downhill, abandoned by Google daddy.

I don’t know better alternatives.

It still works. But once in a while when I need to make changes to CI process, it can get frustrating.

Here’s what I was trying to do: we have another Apple developer account, so we now need to specify which team.

Which ID ?

Fastlane has the parameters team_id, itc_team_id and dev_portal_team_id.

While there’s actually 2 IDs from Apple:

  1. App Store Connect Team ID eg. 12345678 (integers only)
  2. Developer Portal Team ID eg. ABCD1234

I couldn’t know which is which, and so I tinker around in Deliverfile and also passing to deliver action. There’s even a team_id action, but not others 🤔

But it just wouldn’t work.

The solution

Turns out, there is no need to specify any team id.

Fortunately, fastlane is open sourced, and I found the code to auto detect which app/team is being used:

def find_app(options)
   app_identifier = options[:app_identifier]
   app_id = options[:app] if app_identifier.to_s.empty?

   if !app_identifier.to_s.empty?
     app = Spaceship::ConnectAPI::App.find(app_identifier)
   elsif !app_id.kind_of?(Spaceship::ConnectAPI::App) && !app_id.to_s.empty?
     app = Spaceship::ConnectAPI::App.get(app_id: app_id)
   end

   Deliver.cache[:app] = app

   unless app
     UI.user_error!("Could not find app with app identifier '#{options[:app_identifier]}' in your App Store Connect account (#{options[:username]} - Team: #{Spaceship::Tunes.client.team_id})")
   end
 end

Basically, all that matters is the app_identifier, since it is unique (1 app id belongs to only 1 team).

Make sure you add the new app with the app id in App Store Connect FIRST, as spaceship will attempt to find the app.

That’s all.

I was misled by the fastlane error:

…/deliver/detect_values.rb:54:in find_app: \e[31m[!] undefined method team_id for nil:NilClass\e[0m (NoMethodError)

That is because their code attempted to print a helpful message (see UI.user_error), BUT Spaceship::Tunes.client.team_id is no longer defined.. their spaceship module broke here..

Hence I saw the message on “team_id”, when it should be showing:

Could not find app with app identifier xxx in your App Store Connect account…


Image

@samwize

¯\_(ツ)_/¯

Back to Home