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 {