Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

iPhone step 5: the real iPhone app + iPhone sync switch and iCloud in Release (#212)

Louisbf6cdc33f271
diff --git a/NotchBuddy/Sources/App/AppDelegate.swift b/NotchBuddy/Sources/App/AppDelegate.swift
index cad996da..bca82b95 100644
--- a/NotchBuddy/Sources/App/AppDelegate.swift
+++ b/NotchBuddy/Sources/App/AppDelegate.swift
@@ -19,7 +19,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
setupMenuBarItem()
setupIsland()
#if PHONE_LINK
- CloudProbe.shared.start()
+ CloudProbe.shared.startIfEnabled()
#endif
}
diff --git a/NotchBuddy/Sources/App/PhoneLink/CloudProbe.swift b/NotchBuddy/Sources/App/PhoneLink/CloudProbe.swift
index 4f44ef04..43d48ed2 100644
--- a/NotchBuddy/Sources/App/PhoneLink/CloudProbe.swift
+++ b/NotchBuddy/Sources/App/PhoneLink/CloudProbe.swift
@@ -2,7 +2,11 @@
import AppKit
import CloudKit
-// MARK: - iPhone link spike (DebugCloud only)
+// MARK: - iPhone link
+//
+// Starts and stops the iPhone sync (Settings → General → iPhone, off by
+// default): push registration and SessionPublisher. Nothing runs and nothing
+// is sent to iCloud while it is off.
//
// Step 1 spike, kept for testing: when the phoneLinkPing default is on, proves
// that the Mac and the iPhone app share a private CloudKit database:
@@ -45,7 +49,31 @@ final class CloudProbe {
Host.current().localizedName ?? ProcessInfo.processInfo.hostName
}
- func start() {
+ static let enabledKey = "iPhoneSyncEnabled"
+
+ static var isEnabled: Bool { UserDefaults.standard.bool(forKey: enabledKey) }
+
+ /// Called at launch: starts only if the user turned the iPhone sync on.
+ func startIfEnabled() {
+ if Self.isEnabled { start() }
+ }
+
+ func setEnabled(_ on: Bool) {
+ UserDefaults.standard.set(on, forKey: Self.enabledKey)
+ if on { start() } else { stop() }
+ }
+
+ private func stop() {
+ guard started else { return }
+ started = false
+ pingTask?.cancel(); pingTask = nil
+ pollTask?.cancel(); pollTask = nil
+ NSApplication.shared.unregisterForRemoteNotifications()
+ SessionPublisher.shared.stop()
+ log("iPhone sync off")
+ }
+
+ private func start() {
guard !started else { return }
started = true
#if DEBUG
diff --git a/NotchBuddy/Sources/App/PhoneLink/SessionPublisher.swift b/NotchBuddy/Sources/App/PhoneLink/SessionPublisher.swift
index 392c4925..5bbda7a9 100644
--- a/NotchBuddy/Sources/App/PhoneLink/SessionPublisher.swift
+++ b/NotchBuddy/Sources/App/PhoneLink/SessionPublisher.swift
@@ -29,6 +29,28 @@ final class SessionPublisher {
private var publishing = false
private var pending: [String: SessionSnapshot]?
+ /// Stops publishing and deletes this Mac's sessions from iCloud.
+ func stop() {
+ cancellable = nil
+ pending = nil
+ Task {
+ do {
+ let existing = try await existingSessions()
+ let ids = existing.keys.map { SessionSnapshot.recordID(for: $0) }
+ if !ids.isEmpty {
+ _ = try await database.modifyRecords(saving: [], deleting: ids, savePolicy: .changedKeys, atomically: false)
+ }
+ log("publisher off, removed \(ids.count) session(s) from iCloud")
+ } catch let error as CKError where error.code == .zoneNotFound || error.code == .userDeletedZone {
+ log("publisher off, nothing in iCloud")
+ } catch {
+ log("publisher off, cleanup failed: \(error.localizedDescription)")
+ }
+ published = [:]
+ cleanedUp = false
+ }
+ }
+
func start() {
guard cancellable == nil else { return }
let state = AppState.shared
diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swift
index 0291f673..9e1562b6 100644
--- a/NotchBuddy/Sources/App/SettingsView.swift
+++ b/NotchBuddy/Sources/App/SettingsView.swift
@@ -95,6 +95,9 @@ struct SettingsView: View {
// Sidebar selection persisted across sessions
@AppStorage("settingsSection") private var selectedSection: String = "general"
+ #if PHONE_LINK
+ @AppStorage("iPhoneSyncEnabled") private var iPhoneSyncEnabled = false
+ #endif
private var appVersion: String {
Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
@@ -290,6 +293,20 @@ struct SettingsView: View {
.onChange(of: launchAtStartup) { _, on in toggleStartup(on) }
.padding(6)
}
+
+ #if PHONE_LINK
+ GroupBox("iPhone") {
+ VStack(alignment: .leading, spacing: 6) {
+ Toggle("Show my agent sessions on my iPhone", isOn: $iPhoneSyncEnabled)
+ .onChange(of: iPhoneSyncEnabled) { _, on in CloudProbe.shared.setEnabled(on) }
+ Text("Sends your sessions to your private iCloud for the Coucou iPhone app. Project names, commands and questions are encrypted with your iCloud keys. Turning it off deletes them from iCloud.")
+ .font(.system(size: 11))
+ .foregroundColor(.secondary)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ .padding(6)
+ }
+ #endif
}
// MARK: - Active pills section
diff --git a/NotchBuddy/Sources/Phone/CoucouPhoneApp.swift b/NotchBuddy/Sources/Phone/CoucouPhoneApp.swift
index 345bb71c..e2a7ea00 100644
--- a/NotchBuddy/Sources/Phone/CoucouPhoneApp.swift
+++ b/NotchBuddy/Sources/Phone/CoucouPhoneApp.swift
@@ -3,8 +3,8 @@ import UIKit
import UserNotifications
import CloudKit
-// Coucou on iPhone — step 1 spike: a "link test" screen that shows the Pings
-// written by the Mac in the shared private CloudKit zone and answers with Pongs.
+// Coucou on iPhone: the agent sessions your Mac publishes to iCloud
+// (SessionPublisher on the Mac, PhoneLink here).
@main
struct CoucouPhoneApp: App {
@@ -13,7 +13,8 @@ struct CoucouPhoneApp: App {
var body: some Scene {
WindowGroup {
- LinkTestView(link: PhoneLink.shared)
+ HomeView(link: PhoneLink.shared)
+ .preferredColorScheme(.dark)
}
.onChange(of: scenePhase) { _, phase in
if phase == .active { Task { await PhoneLink.shared.refresh() } }
diff --git a/NotchBuddy/Sources/Phone/HomeView.swift b/NotchBuddy/Sources/Phone/HomeView.swift
new file mode 100644
index 00000000..b0d24978
--- /dev/null
+++ b/NotchBuddy/Sources/Phone/HomeView.swift
@@ -0,0 +1,158 @@
+import SwiftUI
+
+/// Main screen: the notch on top, then every agent session from the Mac,
+/// most urgent first.
+struct HomeView: View {
+ let link: PhoneLink
+
+ var body: some View {
+ NavigationStack {
+ ScrollView {
+ VStack(spacing: 16) {
+ NotchHeader(sessions: link.sessions, status: link.status)
+ if link.sessions.isEmpty {
+ EmptySessionsView(status: link.status)
+ } else {
+ VStack(spacing: 0) {
+ let sorted = link.sessions.sortedByUrgency()
+ ForEach(sorted) { session in
+ NavigationLink(value: session.id) {
+ SessionRow(session: session)
+ }
+ .buttonStyle(.plain)
+ if session.id != sorted.last?.id {
+ Divider().padding(.leading, 64)
+ }
+ }
+ }
+ .padding(.vertical, 6)
+ .background(Color(white: 0.11), in: RoundedRectangle(cornerRadius: 22))
+ }
+ }
+ .padding(.horizontal, 16)
+ .padding(.bottom, 24)
+ }
+ .background(Color.black)
+ .refreshable { await link.refresh() }
+ .navigationDestination(for: String.self) { id in
+ SessionDetailView(link: link, sessionId: id)
+ }
+ .toolbar {
+ // Step 1-3 test screens (the link test has its own "Kit" button).
+ ToolbarItem(placement: .topBarTrailing) {
+ NavigationLink {
+ LinkTestView(link: link)
+ } label: {
+ Image(systemName: "stethoscope")
+ }
+ }
+ }
+ }
+ }
+}
+
+/// The black island at the top: Mochi with the most urgent state and a summary.
+struct NotchHeader: View {
+ let sessions: [SessionItem]
+ let status: PhoneLink.Status
+
+ var body: some View {
+ HStack(spacing: 14) {
+ MochiStill(state: sessions.leadState)
+ .frame(width: 52, height: 52)
+ VStack(alignment: .leading, spacing: 3) {
+ Text(headline)
+ .font(.headline)
+ .foregroundStyle(.white)
+ if let detail {
+ Text(detail)
+ .font(.subheadline)
+ .foregroundStyle(.white.opacity(0.6))
+ .lineLimit(1)
+ }
+ }
+ Spacer(minLength: 0)
+ }
+ .padding(.horizontal, 18)
+ .padding(.vertical, 14)
+ .background(Color.black, in: RoundedRectangle(cornerRadius: 28))
+ .overlay(
+ RoundedRectangle(cornerRadius: 28)
+ .strokeBorder(sessions.contains(where: \.isWaitingForYou) ? Color.orange.opacity(0.8) : Color.white.opacity(0.12),
+ lineWidth: 1.5)
+ )
+ }
+
+ private var headline: String {
+ switch status {
+ case .noAccount: return "iCloud not connected"
+ case .failed: return "Can't reach iCloud"
+ default: break
+ }
+ return sessions.summary ?? (sessions.isEmpty ? "Nothing yet" : "All quiet")
+ }
+
+ private var detail: String? {
+ guard let lead = sessions.sortedByUrgency().first else { return nil }
+ return "\(lead.title) · \(lead.statusText)"
+ }
+}
+
+struct SessionRow: View {
+ let session: SessionItem
+
+ var body: some View {
+ HStack(spacing: 12) {
+ MochiStill(state: session.state)
+ .padding(4)
+ .frame(width: 40, height: 40)
+ .background(Color(hex: session.color), in: RoundedRectangle(cornerRadius: 11))
+ VStack(alignment: .leading, spacing: 2) {
+ Text(session.title)
+ .font(.body.weight(.semibold))
+ .lineLimit(1)
+ Text(session.pillName)
+ .font(.subheadline)
+ .foregroundStyle(.secondary)
+ }
+ Spacer(minLength: 8)
+ VStack(alignment: .trailing, spacing: 2) {
+ Text(session.statusText)
+ .font(.subheadline.weight(session.isWaitingForYou ? .semibold : .regular))
+ .foregroundStyle(session.statusColor)
+ Text(session.updatedAt, style: .relative)
+ .font(.caption2)
+ .foregroundStyle(.tertiary)
+ }
+ }
+ .padding(.horizontal, 14)
+ .padding(.vertical, 10)
+ .contentShape(Rectangle())
+ }
+}
+
+struct EmptySessionsView: View {
+ let status: PhoneLink.Status
+
+ var body: some View {
+ VStack(spacing: 8) {
+ Text(message)
+ .font(.subheadline)
+ .foregroundStyle(.secondary)
+ .multilineTextAlignment(.center)
+ }
+ .frame(maxWidth: .infinity)
+ .padding(24)
+ .background(Color(white: 0.11), in: RoundedRectangle(cornerRadius: 22))
+ }
+
+ private var message: String {
+ switch status {
+ case .starting: "Connecting to iCloud…"
+ case .noAccount(let reason): "\(reason) Sign in to iCloud with the same account as your Mac."
+ case .zoneMissing: "Open Coucou on your Mac: your sessions will show up here."
+ case .failed(let message): message
+ case .ready: "No session yet. Start Claude Code, Cursor or Codex on your Mac."
+ }
+ }
+}
diff --git a/NotchBuddy/Sources/Phone/LinkTestView.swift b/NotchBuddy/Sources/Phone/LinkTestView.swift
index 22947f1d..3ff0a208 100644
--- a/NotchBuddy/Sources/Phone/LinkTestView.swift
+++ b/NotchBuddy/Sources/Phone/LinkTestView.swift
@@ -5,7 +5,6 @@ struct LinkTestView: View {
@State private var sending = false
var body: some View {
- NavigationStack {
List {
Section {
statusRow
@@ -96,7 +95,6 @@ struct LinkTestView: View {
.toolbar {
NavigationLink("Kit") { KitPreviewView() }
}
- }
}
@ViewBuilder private var statusRow: some View {
diff --git a/NotchBuddy/Sources/Phone/PhoneLink.swift b/NotchBuddy/Sources/Phone/PhoneLink.swift
index 918af19f..2b8fa002 100644
--- a/NotchBuddy/Sources/Phone/PhoneLink.swift
+++ b/NotchBuddy/Sources/Phone/PhoneLink.swift
@@ -27,6 +27,7 @@ struct SessionItem: Identifiable {
let approvalCommand: String
let question: String
let finalLine: String
+ let cwd: String
let updatedAt: Date
let macName: String
@@ -41,6 +42,7 @@ struct SessionItem: Identifiable {
approvalCommand = record.encryptedValues["approvalCommand"] as? String ?? ""
question = record.encryptedValues["question"] as? String ?? ""
finalLine = record.encryptedValues["finalLine"] as? String ?? ""
+ cwd = record.encryptedValues["cwd"] as? String ?? ""
updatedAt = record["updatedAt"] as? Date ?? record.modificationDate ?? .now
macName = record["macName"] as? String ?? ""
}
diff --git a/NotchBuddy/Sources/Phone/SessionDetailView.swift b/NotchBuddy/Sources/Phone/SessionDetailView.swift
new file mode 100644
index 00000000..3eeaf076
--- /dev/null
+++ b/NotchBuddy/Sources/Phone/SessionDetailView.swift
@@ -0,0 +1,128 @@
+import SwiftUI
+
+/// One session: what the agent is doing, its plan, and what it waits for.
+struct SessionDetailView: View {
+ let link: PhoneLink
+ let sessionId: String
+
+ private var session: SessionItem? { link.sessions.first { $0.id == sessionId } }
+
+ var body: some View {
+ ScrollView {
+ if let session {
+ VStack(alignment: .leading, spacing: 16) {
+ header(session)
+ if session.needsApproval {
+ waiting(title: "Waiting for your OK",
+ text: session.approvalCommand.isEmpty ? "The agent asks for a permission." : session.approvalCommand,
+ monospaced: true, color: .orange,
+ footnote: "Answer on your Mac for now. Approving from the iPhone comes next.")
+ } else if !session.question.isEmpty {
+ waiting(title: "Question", text: session.question, monospaced: false, color: .cyan,
+ footnote: "Answer on your Mac for now.")
+ }
+ if !session.steps.isEmpty { plan(session) }
+ if !session.finalLine.isEmpty {
+ card(title: "Last message") {
+ Text(session.finalLine)
+ .font(.callout)
+ .textSelection(.enabled)
+ }
+ }
+ if !session.cwd.isEmpty {
+ card(title: "Folder") {
+ Text(session.cwd)
+ .font(.footnote.monospaced())
+ .foregroundStyle(.secondary)
+ .textSelection(.enabled)
+ }
+ }
+ }
+ .padding(16)
+ } else {
+ Text("This session ended on your Mac.")
+ .foregroundStyle(.secondary)
+ .padding(40)
+ }
+ }
+ .background(Color.black)
+ .navigationTitle(session?.title ?? "Session")
+ .navigationBarTitleDisplayMode(.inline)
+ .refreshable { await link.refresh() }
+ }
+
+ private func header(_ session: SessionItem) -> some View {
+ HStack(spacing: 16) {
+ MochiStill(state: session.state)
+ .padding(10)
+ .frame(width: 84, height: 84)
+ .background(Color(hex: session.color), in: RoundedRectangle(cornerRadius: 22))
+ VStack(alignment: .leading, spacing: 4) {
+ Text("\(session.pillName) · \(session.title)")
+ .font(.headline)
+ Text(session.statusText)
+ .font(.subheadline.weight(.semibold))
+ .foregroundStyle(session.statusColor)
+ HStack(spacing: 4) {
+ if !session.macName.isEmpty {
+ Text(session.macName)
+ Text("·")
+ }
+ Text(session.updatedAt, style: .relative)
+ }
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+ Spacer(minLength: 0)
+ }
+ }
+
+ private func waiting(title: String, text: String, monospaced: Bool, color: Color, footnote: String) -> some View {
+ VStack(alignment: .leading, spacing: 10) {
+ Text(title).font(.subheadline.weight(.semibold)).foregroundStyle(color)
+ Text(text)
+ .font(monospaced ? .callout.monospaced() : .callout)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(12)
+ .background(Color(white: 0.16), in: RoundedRectangle(cornerRadius: 12))
+ .textSelection(.enabled)
+ Text(footnote).font(.caption).foregroundStyle(.secondary)
+ }
+ .padding(16)
+ .background(Color(white: 0.11), in: RoundedRectangle(cornerRadius: 22))
+ .overlay(RoundedRectangle(cornerRadius: 22).strokeBorder(color.opacity(0.7), lineWidth: 1.5))
+ }
+
+ private func plan(_ session: SessionItem) -> some View {
+ card(title: "Activity · \(min(session.stepIndex + 1, session.steps.count))/\(session.steps.count)") {
+ VStack(alignment: .leading, spacing: 8) {
+ ForEach(Array(session.steps.enumerated()), id: \.offset) { index, step in
+ HStack(alignment: .firstTextBaseline, spacing: 10) {
+ Image(systemName: icon(index, session))
+ .foregroundStyle(index == session.stepIndex && session.isWorking ? Color.accentColor : Color.secondary)
+ .font(.footnote)
+ Text(step)
+ .font(.callout)
+ .foregroundStyle(index > session.stepIndex ? Color.secondary : Color.primary)
+ }
+ }
+ }
+ }
+ }
+
+ private func icon(_ index: Int, _ session: SessionItem) -> String {
+ if index < session.stepIndex || session.state == .finished { return "checkmark.circle.fill" }
+ if index == session.stepIndex { return "circle.dotted" }
+ return "circle"
+ }
+
+ private func card<Content: View>(title: String, @ViewBuilder content: () -> Content) -> some View {
+ VStack(alignment: .leading, spacing: 10) {
+ Text(title).font(.subheadline.weight(.semibold)).foregroundStyle(.secondary)
+ content()
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(16)
+ .background(Color(white: 0.11), in: RoundedRectangle(cornerRadius: 22))
+ }
+}
diff --git a/NotchBuddy/Sources/Phone/SessionStatus.swift b/NotchBuddy/Sources/Phone/SessionStatus.swift
new file mode 100644
index 00000000..479d360b
--- /dev/null
+++ b/NotchBuddy/Sources/Phone/SessionStatus.swift
@@ -0,0 +1,71 @@
+import SwiftUI
+
+// How a session reads on the iPhone: short status line, urgency for sorting,
+// and the summary shown in the notch.
+
+extension SessionItem {
+ /// Lower = more urgent. Waiting on you first, then errors, then work, then rest.
+ var urgency: Int {
+ if needsApproval || state == .approval { return 0 }
+ if !question.isEmpty || state == .question { return 1 }
+ switch state {
+ case .error, .ratelimit, .dizzy: return 2
+ case .working, .thinking, .searching: return 3
+ case .finished: return 4
+ default: return 5
+ }
+ }
+
+ var isWaitingForYou: Bool { urgency <= 1 }
+ var isWorking: Bool { urgency == 3 }
+
+ var statusText: String {
+ if needsApproval || state == .approval { return "waiting for your OK" }
+ if !question.isEmpty || state == .question { return "has a question" }
+ switch state {
+ case .working, .thinking, .searching:
+ return steps.isEmpty ? "working" : "working · \(min(stepIndex + 1, steps.count))/\(steps.count)"
+ case .finished: return "✓ done"
+ case .error: return "error"
+ case .ratelimit: return "rate limited"
+ case .sleeping: return "asleep"
+ case .dizzy: return "dizzy"
+ default: return "idle"
+ }
+ }
+
+ var statusColor: Color {
+ switch urgency {
+ case 0: .orange
+ case 1: .cyan
+ case 2: .red
+ case 4: .green
+ default: .secondary
+ }
+ }
+
+ var title: String { name.isEmpty ? pillName : name }
+}
+
+extension Array where Element == SessionItem {
+ func sortedByUrgency() -> [SessionItem] {
+ sorted { ($0.urgency, $1.updatedAt) < ($1.urgency, $0.updatedAt) }
+ }
+
+ /// "2 working · 1 waiting", or nil when nothing is going on.
+ var summary: String? {
+ let waiting = filter(\.isWaitingForYou).count
+ let working = filter(\.isWorking).count
+ var parts: [String] = []
+ if working > 0 { parts.append("\(working) working") }
+ if waiting > 0 { parts.append("\(waiting) waiting") }
+ return parts.isEmpty ? nil : parts.joined(separator: " · ")
+ }
+
+ /// The state Mochi shows in the notch: the most urgent session's.
+ var leadState: BotState {
+ guard let lead = sortedByUrgency().first else { return .sleeping }
+ if lead.isWaitingForYou { return lead.needsApproval ? .approval : .question }
+ return lead.state
+ }
+}
diff --git a/NotchBuddy/project.yml b/NotchBuddy/project.yml
index 87f9b026..d8b7fc8a 100644
--- a/NotchBuddy/project.yml
+++ b/NotchBuddy/project.yml
@@ -11,7 +11,8 @@ options:
# same for a Developer ID build with its provisioning profile
# (scripts/cloud-test-build.sh); a Developer ID profile only allows the
# Production CloudKit environment, so the iPhone joins it with the
-# CoucouPhoneProduction scheme. Debug and Release are unchanged.
+# CoucouPhoneProduction scheme. Release also compiles PHONE_LINK (the sync
+# stays off until turned on in Settings); Debug stays unsigned without it.
configs:
Debug: debug
DebugCloud: debug
@@ -144,6 +145,12 @@ targets:
DebugCloud:
CODE_SIGN_ENTITLEMENTS: Resources/CoucouCloud.entitlements
SWIFT_ACTIVE_COMPILATION_CONDITIONS: "DEBUG PHONE_LINK"
+ # The distributed build carries the iPhone sync (off until the user
+ # turns it on in Settings), so it needs iCloud and its Developer ID profile.
+ Release:
+ CODE_SIGN_ENTITLEMENTS: Resources/CoucouReleaseCloud.entitlements
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: PHONE_LINK
+ PROVISIONING_PROFILE_SPECIFIER: "Coucou Developer ID"
ReleaseCloud:
CODE_SIGN_ENTITLEMENTS: Resources/CoucouReleaseCloud.entitlements
SWIFT_ACTIVE_COMPILATION_CONDITIONS: PHONE_LINK
@@ -195,6 +202,11 @@ targets:
DebugCloud:
CODE_SIGN_ENTITLEMENTS: Resources/CoucouAppStoreCloud.entitlements
SWIFT_ACTIVE_COMPILATION_CONDITIONS: "APPSTORE PHONE_LINK"
+ # App Store archive: same iCloud entitlements; Xcode switches push to
+ # production when exporting for the App Store.
+ Release:
+ CODE_SIGN_ENTITLEMENTS: Resources/CoucouAppStoreCloud.entitlements
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: "APPSTORE PHONE_LINK"
# iPhone app. Same bundle ID as the Mac App Store build, for universal purchase.
CoucouPhone:
diff --git a/scripts/release.sh b/scripts/release.sh
index b2cbfcf4..bd3fe4b6 100755
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -64,6 +64,25 @@ if [ "$MODE" != "--finish" ]; then
[ -n "$IDENTITY" ] || die "no 'Developer ID Application' certificate found. Install it via Xcode → Settings → Accounts."
echo "Signing with: $IDENTITY"
+ # ── 1b. Developer ID provisioning profile (iCloud for the iPhone sync) ──────
+ PROFILE_NAME="Coucou Developer ID"
+ PROFILE_FOUND=""
+ TMP_PLIST=$(mktemp)
+ 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
+ [ "$(/usr/libexec/PlistBuddy -c "Print :Name" "$TMP_PLIST" 2>/dev/null || true)" = "$PROFILE_NAME" ] || continue
+ PROFILE_FOUND="$f"
+ break 2
+ done
+ done
+ [ -n "$PROFILE_FOUND" ] || { rm -f "$TMP_PLIST"; die "no provisioning profile named '$PROFILE_NAME'. developer.apple.com → Profiles → Developer ID (Mac) for fr.louisraille.NotchBuddy, then copy it to ~/Library/Developer/Xcode/UserData/Provisioning Profiles/"; }
+ EXPIRY=$(/usr/libexec/PlistBuddy -c "Print :ExpirationDate" "$TMP_PLIST")
+ rm -f "$TMP_PLIST"
+ echo "Profile: $PROFILE_FOUND (expires $EXPIRY)"
+
# ── 2. xcodegen + Release build ─────────────────────────────────────────────
cd "$REPO_ROOT/NotchBuddy"
PLIST_VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" Resources/Info.plist 2>/dev/null || true)
@@ -85,6 +104,10 @@ if [ "$MODE" != "--finish" ]; then
CODE_SIGNING_ALLOWED=YES \
CONFIGURATION_BUILD_DIR="$BUILD_DIR"
+ [ -f "$APP/Contents/embedded.provisionprofile" ] || die "the provisioning profile was not embedded in the app"
+ codesign -d --entitlements - --xml "$APP" 2>/dev/null | grep -q "iCloud.fr.louisraille.Coucou" \
+ || die "the app is not signed with the iCloud entitlements"
+
# ── 3. Zip + notarize ───────────────────────────────────────────────────────
ditto -c -k --keepParent "$APP" "$ZIP"
echo