From c6fa6386fd20f5bde410dabe02a8f49f0ea82dec Mon Sep 17 00:00:00 2001 From: Trey t Date: Tue, 10 Feb 2026 19:30:50 -0600 Subject: [PATCH] debug: add CloudKit container diagnostics to sync logs Logs bundle ID, CKContainer.default() identifier, and iCloud account status at sync start to help diagnose "Invalid bundle ID for container" errors on TestFlight. Co-Authored-By: Claude Opus 4.6 --- SportsTime/SportsTimeApp.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/SportsTime/SportsTimeApp.swift b/SportsTime/SportsTimeApp.swift index dfdbd99..9672693 100644 --- a/SportsTime/SportsTimeApp.swift +++ b/SportsTime/SportsTimeApp.swift @@ -8,6 +8,7 @@ import SwiftUI import SwiftData import BackgroundTasks +import CloudKit @main struct SportsTimeApp: App { @@ -238,6 +239,21 @@ struct BootstrappedContentView: View { let log = SyncLogger.shared log.log("🔄 [SYNC] Starting background sync...") + // Log diagnostic info for debugging CloudKit container issues + let bundleId = Bundle.main.bundleIdentifier ?? "unknown" + let container = CKContainer.default() + let containerId = container.containerIdentifier ?? "unknown" + log.log("🔧 [DIAG] Bundle ID: \(bundleId)") + log.log("🔧 [DIAG] CKContainer.default(): \(containerId)") + if let entitlementContainers = Bundle.main.object(forInfoDictionaryKey: "com.apple.developer.icloud-container-identifiers") as? [String] { + log.log("🔧 [DIAG] Entitlement containers: \(entitlementContainers.joined(separator: ", "))") + } + if let accountStatus = try? await container.accountStatus() { + log.log("🔧 [DIAG] iCloud account status: \(accountStatus.rawValue) (0=couldNotDetermine, 1=available, 2=restricted, 3=noAccount)") + } else { + log.log("🔧 [DIAG] iCloud account status: failed to check") + } + // Only reset stale syncInProgress flags; do not clobber an actively running sync. let syncState = SyncState.current(in: context) if syncState.syncInProgress {