Matthias Nott
2026-06-11 54a1fd0ffbd9b663bd9aa502009ea54faae3b304
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# PAILot App Store Build Script
# Builds an iOS IPA and uploads it to App Store Connect.
# Adapted from Glidr's pipeline — same Apple Dev Team (7KU642K5ZL).
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
APP_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$APP_DIR"
# App Store Connect API credentials (issuer is shared across keys for this team).
ASC_KEY_ID="${ASC_KEY_ID:-4H68LK2M3J}"
ASC_ISSUER_ID="${ASC_ISSUER_ID:-69a6de75-2050-47e3-e053-5b8c7c11a4d1}"
ASC_KEY_PATH="${ASC_KEY_PATH:-$HOME/.appstoreconnect/private_keys/AuthKey_${ASC_KEY_ID}.p8}"
TEAM_ID="7KU642K5ZL"
if [ ! -f "$ASC_KEY_PATH" ]; then
  echo "ERROR: App Store Connect API key not found at $ASC_KEY_PATH"
  echo "       Download from https://appstoreconnect.apple.com/access/api"
  exit 1
fi
# Homebrew rsync breaks Xcode's export step — temporarily hide it.
BREW_RSYNC="$(brew --prefix 2>/dev/null)/bin/rsync"
RSYNC_MOVED=false
if [ -f "$BREW_RSYNC" ]; then
  mv "$BREW_RSYNC" "${BREW_RSYNC}.bak"
  RSYNC_MOVED=true
  echo "  Temporarily hid Homebrew rsync"
fi
cleanup() {
  if [ "$RSYNC_MOVED" = true ] && [ -f "${BREW_RSYNC}.bak" ]; then
    mv "${BREW_RSYNC}.bak" "$BREW_RSYNC"
    echo "  Restored Homebrew rsync"
  fi
}
trap cleanup EXIT
echo "=== Building IPA for App Store ==="
flutter build ipa --release --export-method development --no-tree-shake-icons
echo ""
echo "=== Fixing archive name ==="
ARCHIVE="build/ios/archive/Runner.xcarchive/Info.plist"
if [ -f "$ARCHIVE" ]; then
  plutil -replace Name -string "PAILot" "$ARCHIVE"
  plutil -replace SchemeName -string "PAILot" "$ARCHIVE"
  echo "  Archive name set to 'PAILot'"
fi
echo ""
echo "=== Exporting and uploading to App Store Connect ==="
cat > /tmp/PAILotAppStoreExport.plist <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>method</key>
    <string>app-store-connect</string>
    <key>destination</key>
    <string>upload</string>
    <key>signingStyle</key>
    <string>automatic</string>
    <key>teamID</key>
    <string>${TEAM_ID}</string>
</dict>
</plist>
PLIST
rm -rf /tmp/pailot-appstore-export 2>/dev/null
xcodebuild -exportArchive \
  -archivePath build/ios/archive/Runner.xcarchive \
  -exportOptionsPlist /tmp/PAILotAppStoreExport.plist \
  -exportPath /tmp/pailot-appstore-export \
  -allowProvisioningUpdates \
  -authenticationKeyPath "$ASC_KEY_PATH" \
  -authenticationKeyID "$ASC_KEY_ID" \
  -authenticationKeyIssuerID "$ASC_ISSUER_ID"
echo ""
echo "=== Done ==="
echo "Uploaded to App Store Connect. Next: complete the build's metadata and submit for review."