Files
coucou/scripts/cloud-test-build.sh
LouisandClaude Opus 5.5 2d3a1692ac iPhone steps 1–2: CloudKit link spike + Developer ID build with iCloud (#209)
* iPhone link spike: CloudKit Ping/Pong between the Mac and a new iPhone app

Adds a DebugCloud configuration (signed, PHONE_LINK) with NotchBuddyCloud and
CoucouAppStoreCloud schemes, a CoucouPhone iOS target, and a CloudKit probe on
the Mac that writes a Ping every 60 s and logs the iPhone's Pong round trip.
Debug and Release are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p

* PhoneLink: log to the Xcode console too, list subscriptions, log every remote notification

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p

* Fix the App Store build: hide Mac-only shortcuts with a filtered list

A bare return inside the ForEach ViewBuilder closure broke the CoucouAppStore
compile. Also build CoucouAppStore in CI so this is caught.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p

* iPhone step 2: Developer ID build with iCloud (ReleaseCloud + cloud-test-build.sh)

Adds a ReleaseCloud configuration (Developer ID, 'Coucou Developer ID'
provisioning profile, iCloud entitlements, PHONE_LINK) and a script that
builds and checks it without notarizing. Release and release.sh are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p

* cloud-test-build.sh: explain how to copy the profile for Xcode instead of double-clicking it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p

* Step 2: use the Production CloudKit environment for the Developer ID build

A Developer ID provisioning profile only allows Production. Adds the
CoucouPhoneProduction scheme so the iPhone app can join it from Xcode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qkcwzfTWvbmbc2y9dur6p

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-04 20:56:10 +02:00

90 lines
4.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# iPhone plan, step 2: builds the GitHub app (fr.louisraille.NotchBuddy) the
# way release.sh does — Release optimizations, Developer ID signature — plus
# the "Coucou Developer ID" provisioning profile, the iCloud entitlements and
# the PHONE_LINK probe. Not notarized, not published: it only proves that a
# Developer ID build can talk to iCloud. A Developer ID profile only allows the
# Production CloudKit environment: the Ping/Pong schema must be deployed to
# Production in the CloudKit Console first.
#
# ./scripts/cloud-test-build.sh
#
# The normal release (scripts/release.sh, Release configuration) is unchanged.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
BUILD_DIR="/tmp/coucou-cloud-test"
APP="$BUILD_DIR/Coucou.app"
PROFILE_NAME="Coucou Developer ID"
APP_ID="256AUJ9555.fr.louisraille.NotchBuddy"
CONTAINER="iCloud.fr.louisraille.Coucou"
die() { echo "error: $*" >&2; exit 1; }
# ── 1. Developer ID identity ──────────────────────────────────────────────────
IDENTITY=$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | sed 's/.*"\(Developer ID Application[^"]*\)".*/\1/' || true)
[ -n "$IDENTITY" ] || die "no 'Developer ID Application' certificate found. Install it via Xcode → Settings → Accounts."
echo "Signing with: $IDENTITY"
# ── 2. Provisioning profile ───────────────────────────────────────────────────
# Xcode looks in both folders depending on its version. Double-clicking a
# downloaded .provisionprofile on macOS doesn't reliably put it in either.
TMP_PLIST=$(mktemp)
trap 'rm -f "$TMP_PLIST"' EXIT
FOUND=""
for dir in "$HOME/Library/Developer/Xcode/UserData/Provisioning Profiles" "$HOME/Library/MobileDevice/Provisioning Profiles"; do
[ -d "$dir" ] || continue
for f in "$dir"/*.provisionprofile; do
[ -f "$f" ] || continue
security cms -D -i "$f" > "$TMP_PLIST" 2>/dev/null || continue
NAME=$(/usr/libexec/PlistBuddy -c "Print :Name" "$TMP_PLIST" 2>/dev/null || true)
[ "$NAME" = "$PROFILE_NAME" ] || continue
FOUND="$f"
break 2
done
done
[ -n "$FOUND" ] || die "no provisioning profile named '$PROFILE_NAME' is installed.
developer.apple.com → Profiles → + → Developer ID → App ID fr.louisraille.NotchBuddy,
name it exactly '$PROFILE_NAME' and download it. Then copy it for Xcode:
mkdir -p ~/Library/Developer/Xcode/UserData/Provisioning\\ Profiles
cp ~/Downloads/*.provisionprofile ~/Library/Developer/Xcode/UserData/Provisioning\\ Profiles/"
echo "Profile: $FOUND"
PROFILE_APP_ID=$(/usr/libexec/PlistBuddy -c "Print :Entitlements:com.apple.application-identifier" "$TMP_PLIST" 2>/dev/null || true)
[ "$PROFILE_APP_ID" = "$APP_ID" ] || die "the profile is for '$PROFILE_APP_ID', not $APP_ID"
/usr/libexec/PlistBuddy -c "Print :Entitlements:com.apple.developer.icloud-container-identifiers" "$TMP_PLIST" 2>/dev/null | grep -q "$CONTAINER" \
|| die "the profile has no iCloud container $CONTAINER. Turn on iCloud (CloudKit, with that container) on the App ID fr.louisraille.NotchBuddy, then regenerate and reinstall the profile."
EXPIRY=$(/usr/libexec/PlistBuddy -c "Print :ExpirationDate" "$TMP_PLIST")
echo "Profile expires: $EXPIRY"
# ── 3. Build ──────────────────────────────────────────────────────────────────
cd "$REPO_ROOT/NotchBuddy"
xcodegen generate
rm -rf "$BUILD_DIR" && mkdir -p "$BUILD_DIR"
xcodebuild \
-project NotchBuddy.xcodeproj \
-scheme NotchBuddy \
-configuration ReleaseCloud \
build \
CODE_SIGN_IDENTITY="$IDENTITY" \
CONFIGURATION_BUILD_DIR="$BUILD_DIR" \
-quiet \
|| die "the build failed (see the errors above)"
# ── 4. Checks ─────────────────────────────────────────────────────────────────
[ -f "$APP/Contents/embedded.provisionprofile" ] || die "the profile was not embedded in the app"
codesign --verify --deep --strict "$APP" || die "the signature does not verify"
echo
echo "Entitlements of the built app:"
codesign -d --entitlements - --xml "$APP" 2>/dev/null | plutil -p - || true
echo
echo "✓ Built $APP (Developer ID, not notarized)."
echo
echo "To test:"
echo " 1. Quit any other Coucou (menu bar icon → Quit) and stop it in Xcode."
echo " 2. open $APP"
echo " 3. tail -f ~/Library/Logs/NotchBuddy/nb.log | grep PhoneLink"
echo " 4. Developer ID builds use the Production CloudKit environment: run the iPhone"
echo " app with the CoucouPhoneProduction scheme, pull to refresh, then tap Send pong."