DEV Community

MacBuildCloud
MacBuildCloud

Posted on

Your first TestFlight build from Windows: every step, in order (Flutter)

I'm on the MacBuildCloud team; we run Mac build machines, and "how do I get my Flutter app onto TestFlight without a Mac?" is the question we hear most. This guide doesn't use our service: it uses a free GitHub-hosted macOS runner, and everything else happens in a browser and a Windows terminal.

People who build iOS apps from Windows usually don't get stuck on Flutter. They get stuck on the Apple side: which page has which file, what has to exist before what, and why the build fails with a message that doesn't mention the real problem. Here is the whole path, in the order Apple needs it.

What you need

  • A paid Apple Developer Program membership. A free Apple ID can't create a distribution certificate. Sign in as the Account Holder or an Admin of the team.
  • A Flutter app in a GitHub repository. GitHub's standard macOS runners are free for public repositories; on a private repository they use your Actions minutes, and macOS minutes cost more than Linux ones.
  • OpenSSL on Windows. Git for Windows ships one: open Git Bash and run openssl version.

Two Apple websites are involved, and they're easy to mix up:

  • developer.apple.com → Account → Certificates, Identifiers & Profiles: App ID, certificate, provisioning profile.
  • appstoreconnect.apple.com: the app record, the API key, TestFlight.

1. Pick a bundle ID and put it in the project

Choose a reverse-domain ID like com.yourname.yourapp. You can't change it after the first upload.

Without Xcode, edit ios/Runner.xcodeproj/project.pbxproj in any text editor. Search for PRODUCT_BUNDLE_IDENTIFIER: the Runner target has three entries (Debug, Release, Profile). Change those to your ID. The RunnerTests entries end in .RunnerTests; give them your ID plus .RunnerTests.

2. Register the App ID

developer.apple.com → Certificates, Identifiers & Profiles → Identifiers → + → App IDs → App. Enter the exact bundle ID from step 1 as an explicit ID (not a wildcard). Tick any capabilities your app uses, such as Push Notifications.

3. Create the app record

appstoreconnect.apple.com → Apps → + → New App. Pick iOS, a name, a language, your bundle ID from the list, and any SKU (it's only for you). If your bundle ID isn't in the list, step 2 didn't save, or you're on the wrong team (check the team selector at the top right).

4. Make a distribution certificate on Windows

Apple's instructions assume Keychain Access on a Mac. OpenSSL does the same job. In Git Bash:

openssl req -new -newkey rsa:2048 -nodes \
  -keyout ios_distribution.key \
  -out ios_distribution.csr \
  -subj "/emailAddress=you@example.com/CN=Your Name/C=US"
Enter fullscreen mode Exit fullscreen mode

Keep ios_distribution.key safe. Without it, the certificate Apple gives you is useless.

On developer.apple.com → Certificates → + → Apple Distribution, upload ios_distribution.csr and download the .cer. Then combine the key and the certificate into a .p12:

openssl x509 -inform DER -in distribution.cer -out distribution.pem
openssl pkcs12 -export -legacy \
  -inkey ios_distribution.key \
  -in distribution.pem \
  -out distribution.p12
Enter fullscreen mode Exit fullscreen mode

It asks for a password; you'll need it in step 8. About -legacy: OpenSSL 3 changed how .p12 files are protected, and older versions of macOS reject the new format with "MAC verification failed ... (wrong password?)" even when the password is right. Apple fixed this in macOS 15, but -legacy makes a file that every version accepts. If your OpenSSL is older than 3 and doesn't know -legacy, just leave it out.

Apple limits how many distribution certificates a team can have. Make one, keep the .p12 and its password somewhere safe, and reuse it for every build.

5. Create the provisioning profile

developer.apple.com → Profiles → + → Distribution → App Store Connect. Pick your App ID, then the certificate from step 4, give the profile a name you'll remember, and download the .mobileprovision. You'll type that name in step 7.

6. Create an App Store Connect API key

appstoreconnect.apple.com → Users and Access → Integrations → App Store Connect API → +. Give it the App Manager role. Note three things:

  • the Issuer ID at the top of the page,
  • the Key ID in the key's row,
  • the .p8 file. Apple lets you download it once. Keep it.

7. Add ExportOptions.plist

Create ios/ExportOptions.plist. It's plain text, so any editor works:

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
  <key>method</key>          <string>app-store-connect</string>
  <key>teamID</key>          <string>YOURTEAMID</string>
  <key>signingStyle</key>    <string>manual</string>
  <key>provisioningProfiles</key>
  <dict>
    <key>com.yourname.yourapp</key><string>Your Profile Name</string>
  </dict>
</dict>
</plist>
Enter fullscreen mode Exit fullscreen mode

teamID is the 10-character Team ID shown on developer.apple.com under Membership details. The profile value is the profile's name from step 5, not its filename.

While you're in ios/, open ios/Runner/Info.plist. If your app only uses standard HTTPS, add this inside the main <dict> so App Store Connect stops asking the encryption question for every build:

<key>ITSAppUsesNonExemptEncryption</key>
<false/>
Enter fullscreen mode Exit fullscreen mode

8. Build and upload with GitHub Actions

First turn the binary files into text, because GitHub secrets are text. In PowerShell:

[Convert]::ToBase64String([IO.File]::ReadAllBytes("distribution.p12")) | Set-Content p12.txt
[Convert]::ToBase64String([IO.File]::ReadAllBytes("Your_Profile.mobileprovision")) | Set-Content profile.txt
[Convert]::ToBase64String([IO.File]::ReadAllBytes("AuthKey_ABC123XYZ.p8")) | Set-Content p8.txt
Enter fullscreen mode Exit fullscreen mode

In your repository → Settings → Secrets and variables → Actions, add:

Secret Value
P12_BASE64 contents of p12.txt
P12_PASSWORD the password from step 4
PROFILE_BASE64 contents of profile.txt
ASC_KEY_BASE64 contents of p8.txt
ASC_KEY_ID the Key ID
ASC_ISSUER_ID the Issuer ID
KEYCHAIN_PASSWORD any random string

Then add .github/workflows/testflight.yml:

name: TestFlight
on:
  workflow_dispatch:

jobs:
  build:
    runs-on: macos-latest
    timeout-minutes: 60
    steps:
      - uses: actions/checkout@v4
      - uses: subosito/flutter-action@v2
        with:
          channel: stable

      - name: Install certificate and profile
        env:
          P12_BASE64: ${{ secrets.P12_BASE64 }}
          P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
          PROFILE_BASE64: ${{ secrets.PROFILE_BASE64 }}
          KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
        run: |
          KEYCHAIN=$RUNNER_TEMP/build.keychain-db
          echo -n "$P12_BASE64" | base64 --decode -o $RUNNER_TEMP/cert.p12
          echo -n "$PROFILE_BASE64" | base64 --decode -o $RUNNER_TEMP/app.mobileprovision
          security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN
          security set-keychain-settings -lut 21600 $KEYCHAIN
          security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN
          security import $RUNNER_TEMP/cert.p12 -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN
          security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN
          security list-keychain -d user -s $KEYCHAIN
          mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
          cp $RUNNER_TEMP/app.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/
          mkdir -p ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles
          cp $RUNNER_TEMP/app.mobileprovision ~/Library/Developer/Xcode/UserData/Provisioning\ Profiles/

      - name: Build
        run: |
          flutter build ipa --release --no-codesign --build-number=${{ github.run_number }}
          xcodebuild -exportArchive \
            -archivePath build/ios/archive/Runner.xcarchive \
            -exportOptionsPlist ios/ExportOptions.plist \
            -exportPath build/ios/ipa

      - name: Upload to TestFlight
        env:
          ASC_KEY_BASE64: ${{ secrets.ASC_KEY_BASE64 }}
          ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
          ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
        run: |
          mkdir -p ~/.appstoreconnect/private_keys
          echo -n "$ASC_KEY_BASE64" | base64 --decode -o ~/.appstoreconnect/private_keys/AuthKey_$ASC_KEY_ID.p8
          IPA=$(ls build/ios/ipa/*.ipa | head -n 1)
          xcrun altool --upload-app -f "$IPA" -t ios --apiKey "$ASC_KEY_ID" --apiIssuer "$ASC_ISSUER_ID"
Enter fullscreen mode Exit fullscreen mode

Push it, then go to the Actions tab and press Run workflow. (The button only appears once the file is on the default branch.)

Two choices in that file are deliberate:

  • The archive isn't signed; the export is. --no-codesign builds the archive without touching signing, and -exportArchive signs it with your certificate and profile. If you let automatic signing run on a fresh runner instead, Xcode asks Apple for a new certificate every time, and the private key disappears with the runner.
  • --build-number uses the run number, because App Store Connect rejects a build number it has already seen.

9. Find it in TestFlight

After the upload, App Store Connect → your app → TestFlight. The build shows as Processing for a few minutes. Then:

  • Internal testers (people on your App Store Connect team, up to 100) can install it right away, with no review.
  • External testers need Beta App Review, but only for the first build you add to an external group.

Your testers install the TestFlight app on their iPhone and accept the invite.

Where it usually breaks

Message What it usually means
Bundle ID not in the New App list The App ID from step 2 is missing, is a wildcard, or is on another team
MAC verification failed ... (wrong password?) The .p12 was made by OpenSSL 3 without -legacy
No signing certificate "iOS Distribution" found The .p12 has no private key in it, or the certificate expired
No profiles for 'com...' were found Bundle ID in the project doesn't match the profile, or an app extension needs its own profile
Provisioning profile doesn't include signing certificate The profile was made with another certificate; make the profile again
Upload rejected for the key's permissions The API key's role is below App Manager
Upload rejected for the build number That build number was already uploaded

If your app embeds a native framework of its own (Kotlin Multiplatform, for example) and the upload is rejected with ITMS-90035, that framework wasn't signed at export. Signing during the archive step, with the same certificate and profile, is the usual way around it.

Checklist

  • Paid membership, signed in as Account Holder or Admin
  • Bundle ID set in project.pbxproj, registered as an explicit App ID, and used for the app record
  • .p12 made with -legacy, and its password saved
  • App Store provisioning profile for that App ID and certificate
  • API key with App Manager role; .p8, Key ID and Issuer ID saved
  • ExportOptions.plist with your Team ID and the profile's name
  • Workflow on the default branch, started from Run workflow

Top comments (0)