Ship to TestFlight with fastlane
Install fastlane and upload builds with an App Store Connect API key.
Install
fastlane recommends pinning it per project with Bundler. Create a Gemfile in your project with:
source "https://rubygems.org"
gem "fastlane"
then run bundle update, commit both Gemfile and Gemfile.lock, and run lanes with bundle exec fastlane …. Quicker alternative: brew install fastlane. Start with fastlane init in your project folder.
Upload to TestFlight with an API key
An App Store Connect API key avoids two-factor prompts on an unattended Mac. Create one in App Store Connect (Users and Access → Integrations), download the .p8 file to the Mac, and use it in a lane:
lane :beta do
app_store_connect_api_key(
key_id: "YOUR_KEY_ID",
issuer_id: "YOUR_ISSUER_ID",
key_filepath: "./AuthKey_YOUR_KEY_ID.p8"
)
build_app(scheme: "MyApp")
upload_to_testflight
end
Run it with bundle exec fastlane beta, by hand or from your CI runner. Keep the .p8 file out of your repository.