TürkiyeVPS

Upload to TestFlight with Fastlane: Step by Step on a Rented Mac

Stop archiving in Xcode and uploading by hand for every release. App Store Connect API key, Fastfile, code signing (Xcode or match), build numbers and GitHub Actions: a step-by-step guide to one-command TestFlight uploads on a rented Mac.

6 min read

Every new release of an iOS app repeats the same steps: bump the build number, archive in Xcode, sign, upload to App Store Connect. Fastlane wraps those steps into one command. This guide shows how to set up Fastlane on a Mac and upload your app to TestFlight with a single command, then automate the same job with GitHub Actions.

Quick summary: Fastlane does not replace Xcode; it runs Xcode for you. You still need a Mac to build and sign. If you don't own one, you can set it up on a rented Mac mini: the whole Mac is reserved for you and delivered with an admin account.

What you need before you start

  • An Apple Developer Program membership and an app record in App Store Connect (with its Bundle ID).
  • An App Store Connect API key: in App Store Connect go to Users and Access → Integrations → App Store Connect API and create a key with the "App Manager" role. Note the Key ID and Issuer ID and download the .p8 file (it can only be downloaded once). With this key, uploads work without two-factor codes.
  • A Mac with Xcode installed: you will connect over SSH; for the first setup you may need to open the desktop once over VNC (connection guide).

1. Install Fastlane

Homebrew is the easiest way on the Mac:

brew install fastlane
echo 'export LC_ALL=en_US.UTF-8' >> ~/.zshrc
echo 'export LANG=en_US.UTF-8' >> ~/.zshrc
source ~/.zshrc
fastlane --version

The locale lines stop Fastlane from printing encoding warnings in an SSH session.

2. Put the API key on the Mac

Copy the .p8 file from your Windows computer to the Mac and move it to a folder only you can read:

scp AuthKey_ABC123XYZ.p8 user@MAC_IP:~/
ssh user@MAC_IP
mkdir -p ~/.appstoreconnect && mv ~/AuthKey_ABC123XYZ.p8 ~/.appstoreconnect/
chmod 600 ~/.appstoreconnect/AuthKey_ABC123XYZ.p8

3. Initialise Fastlane in the project

Go to the project folder and run fastlane init; choose manual setup in the menu. Fastlane creates fastlane/Appfile and fastlane/Fastfile. Put your Bundle ID in Appfile:

app_identifier("com.company.app")

4. Fastfile: TestFlight in one command

Edit fastlane/Fastfile like this (change the scheme and file names to match your project):

default_platform(:ios)

platform :ios do
  desc "Build a new version and upload it to TestFlight"
  lane :beta do
    api_key = app_store_connect_api_key(
      key_id: ENV["ASC_KEY_ID"],
      issuer_id: ENV["ASC_ISSUER_ID"],
      key_filepath: File.expand_path("~/.appstoreconnect/AuthKey_ABC123XYZ.p8")
    )
    increment_build_number(
      build_number: latest_testflight_build_number(api_key: api_key) + 1
    )
    build_app(
      workspace: "App.xcworkspace",
      scheme: "App",
      export_method: "app-store"
    )
    upload_to_testflight(
      api_key: api_key,
      skip_waiting_for_build_processing: true
    )
  end
end
  • latest_testflight_build_number reads the last build number on TestFlight; using one more avoids the "build number already exists" error. For increment_build_number, set Build Settings → Versioning System to "Apple Generic" in the Xcode project.
  • If you don't use CocoaPods, write project: "App.xcodeproj" instead of workspace.
  • In Flutter projects pubspec.yaml controls the build number; it is simpler to build with flutter build ipa --build-number=... first and keep only the upload_to_testflight(ipa: "build/ios/ipa/app.ipa") step.

5. Code signing: two ways

Way A — Xcode automatic signing (solo developer): connect to the Mac's desktop over VNC once, add your Apple account in Xcode → Settings → Accounts and keep Automatically manage signing on in the project. When you build over SSH and the keychain is locked, signing stops with "errSecInternalComponent"; unlock the keychain before the build:

security unlock-keychain -p "YOUR_MAC_PASSWORD" ~/Library/Keychains/login.keychain-db

Way B — match (teams and CI): keeps certificates and profiles encrypted in a private Git repository, so every Mac uses the same certificate.

fastlane match init        # asks for the private repo URL
fastlane match appstore    # creates the certificate and App Store profile

Then add match(type: "appstore", readonly: true) before the build_app line in the Fastfile. On CI, adding setup_ci at the start of the lane creates a temporary keychain and removes the lock problem.

6. Run it

cd ~/app
ASC_KEY_ID=ABC123XYZ ASC_ISSUER_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx fastlane beta

After the upload the build stays in "Processing" in App Store Connect for a few minutes. Then it appears on the TestFlight tab: internal testers can try it right away, external testers need Apple's beta review. To skip the encryption question every time, add ITSAppUsesNonExemptEncryption = NO to Info.plist if you use no encryption beyond standard HTTPS.

7. Automatic uploads with GitHub Actions

If you made the same Mac a GitHub Actions self-hosted runner, uploading to TestFlight on every release tag looks like this:

name: testflight
on:
  push:
    tags: ["v*"]
jobs:
  beta:
    runs-on: [self-hosted, macOS]
    steps:
      - uses: actions/checkout@v4
      - run: fastlane beta
        env:
          ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
          ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
          MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}

Keep secret values in GitHub under Settings → Secrets and variables → Actions, not in the repository.

Common errors

  • "No profiles for 'com.company.app' were found": check that the Bundle ID matches the App Store Connect record and that the right team is selected; with match, run fastlane match appstore again.
  • "errSecInternalComponent": the keychain is locked; use the security unlock-keychain command above or the setup_ci step.
  • "The bundle version must be higher than the previously uploaded version": the build number was reused; add the latest_testflight_build_number step.
  • Builds take too long or the disk fills up: clean ~/Library/Developer/Xcode/DerivedData and old archives (~/Library/Developer/Xcode/Archives) regularly.

Which Mac is enough?

An Apple M6 Mac mini with 16 GB RAM is plenty for uploading one app to TestFlight. To try the Fastlane setup once, you can rent a Mac for one day; if you upload every release, a monthly plan makes more sense. Current prices: Mac mini rental.

Frequently Asked Questions

Do I need a Mac for Fastlane?

To build and sign an iOS app, yes. Fastlane runs Xcode from the command line, and Xcode only runs on macOS. If you don't own a Mac, you can use a rented Mac you connect to remotely.

Is Fastlane paid?

No, Fastlane is open source and free. Publishing on the App Store also requires an Apple Developer Program membership.

Is my API key safe on a rented Mac?

The Mac is reserved for you and no other customer connects to it. Protect the key file with chmod 600 and revoke the key in App Store Connect when the rental ends. At the end of the rental the Mac is wiped and reset before the next customer.

When does the build appear in TestFlight?

After the upload Apple processes the build; this usually takes a few minutes, sometimes longer. App Store Connect sends an email when it is done.