Automated TestFlight Deployment¶
Method 1: Xcode Cloud (Recommended)¶
Apple's CI/CD service - builds and uploads automatically on git push.
Method 2: Fastlane (Most Popular)¶
# Install fastlane
brew install fastlane
# Initialize in project
cd ios/Nutri-E
fastlane init
# Create Fastfile
fastlane/Fastfile:
default_platform(:ios)
platform :ios do
desc "Push to TestFlight"
lane :beta do
increment_build_number
build_app(scheme: "Nutri-E")
upload_to_testflight
end
end
Method 3: GitHub Actions¶
.github/workflows/testflight.yml:
name: Deploy to TestFlight
on:
push:
branches: [main]
jobs:
deploy:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Build and Upload
env:
APP_STORE_CONNECT_API_KEY: ${{ secrets.API_KEY }}
run: |
xcodebuild archive -scheme Nutri-E -archivePath app.xcarchive
xcodebuild -exportArchive -archivePath app.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath .
xcrun altool --upload-app -f Nutri-E.ipa --apiKey $APP_STORE_CONNECT_API_KEY
Method 4: App Store Connect API Key (For Terminal)¶
- Create API key at https://appstoreconnect.apple.com/access/api
- Download the .p8 file
- Store credentials:
# Create API key config
mkdir -p ~/.appstoreconnect/private_keys
cp AuthKey_XXXXXXXXXX.p8 ~/.appstoreconnect/private_keys/
# Export with API key
xcodebuild -exportArchive \
-archivePath ~/Desktop/Nutri-E.xcarchive \
-exportOptionsPlist ExportOptions.plist \
-exportPath ~/Desktop \
-allowProvisioningUpdates \
-authenticationKeyPath ~/.appstoreconnect/private_keys/AuthKey_XXXXXXXXXX.p8 \
-authenticationKeyID XXXXXXXXXX \
-authenticationKeyIssuerID XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Method 5: xcrun altool with App-Specific Password¶
- Generate app-specific password at https://appleid.apple.com/account/manage
- Store in keychain:
xcrun altool --store-password-in-keychain-item "AC_PASSWORD" \
-u your-apple-id@example.com \
-p app-specific-password
# Then upload
xcrun altool --upload-app \
-f ~/Desktop/Nutri-E.ipa \
-u your-apple-id@example.com \
-p @keychain:AC_PASSWORD
Method 6: Simple Bash Script¶
deploy.sh:
#!/bin/bash
# Increment build number
agvtool next-version -all
# Archive
xcodebuild -project Nutri-E.xcodeproj \
-scheme Nutri-E \
-destination 'generic/platform=iOS' \
-archivePath build/Nutri-E.xcarchive \
archive
# Export
xcodebuild -exportArchive \
-archivePath build/Nutri-E.xcarchive \
-exportOptionsPlist ExportOptions.plist \
-exportPath build
# Upload (requires API key setup)
xcrun altool --upload-app -f build/Nutri-E.ipa \
--apiKey YOUR_KEY_ID \
--apiIssuer YOUR_ISSUER_ID
echo "✅ Deployed to TestFlight!"
Recommended: Fastlane¶
- Most mature and widely used
- Handles certificates automatically
- Great documentation
- Can automate screenshots, metadata, etc.