1

I'm trying to set up Fastfile for upload to Testflight and deliver but for no reason, I can't share my lane_context for app_store_connect_api_key. Here is my Fastfile where I'm wrong.

platform :ios do
   desc "Load ASC API Key information to use in subsequent lanes"
   lane :app_store_connect_api_key do
       app_store_connect_api_key(
       key_id: "key_id",
       issuer_id: "issuerid",
       key_content: "content",
       is_key_content_base64: true,
       duration: 500,
       in_house: false
     )
end
end
  desc "Test auth"
  lane :release do
     app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
     api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
     pilot(
     api_key: api_key,
     app_identifier: app_identifier,
     skip_submission: true,
     skip_waiting_for_build_processing: true
   )
end

When I'm trying to execute the Fastlane release I receive. Thank you! FastLane Pilot

nD0613
  • 135
  • 1
  • 11

2 Answers2

2

You need execute app_store_connect_api_key before use API key in lane context. Like below:

platform :ios do
   desc "Load ASC API Key information to use in subsequent lanes"
   lane :retrieve_api_key do
       app_store_connect_api_key(
       key_id: "key_id",
       issuer_id: "issuerid",
       key_content: "content",
       is_key_content_base64: true,
       duration: 500,
       in_house: false
     )
end
end
  desc "Test auth"
  lane :release do
     retrieve_api_key
     app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
     api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
     pilot(
     api_key: api_key,
     app_identifier: app_identifier,
     skip_submission: true,
     skip_waiting_for_build_processing: true
   )
end
ridvanaltun
  • 2,595
  • 2
  • 15
  • 28
  • Doesn't work I receive a new error Could not find action, lane or variable 'retrieve_api_key'. Check out the documentation for more details: https://docs.fastlane.tools/actions – nD0613 Apr 24 '22 at 07:04
  • You need to define a lane named retrieve_api_key as above I show. – ridvanaltun Apr 25 '22 at 13:18
  • 1
    It was my mistake that works like a charm! Thanks a lot! – nD0613 Apr 25 '22 at 20:02
1

Also, you don't have to specify api_key if it's already in the lane context:

lane :fetch_api_key do

  app_store_connect_api_key(
    key_id: "key_id",
    issuer_id: "issuer_id",
    key_filepath: "key_filepath.p8",
    in_house: false # optional but may be required if using match/sigh
  )
end

desc "Upload to TestFlight"
lane :release do

  fetch_api_key

  pilot(
    ipa: "Your App.ipa", 
    skip_waiting_for_build_processing: true
  )
end

pilot will pick up it automatically

serhii.syrotynin
  • 241
  • 1
  • 14