Fix startup crash in sideloaded builds without iCloud entitlements

Sideloading tools re-sign the app with a team that cannot register the
iCloud.stream.yattee.app container, and CKContainer(identifier:) fatally
traps when the entitlement is missing. Detect availability by parsing
the embedded provisioning profile, skip creating any CloudKit objects
when the entitlement is absent, and show an explanation in iCloud
settings instead of the sync toggle.
This commit is contained in:
Arkadiusz Fal
2026-07-27 20:08:21 +02:00
parent 7c07189023
commit 40f043b769
4 changed files with 135 additions and 28 deletions

View File

@@ -58,24 +58,31 @@ struct iCloudSettingsView: View {
}
#endif
SettingsFormSection(footer: "settings.icloud.footer") {
Toggle(isOn: Binding(
get: { settingsManager?.iCloudSyncEnabled ?? false },
set: { newValue in
if newValue {
showingEnableConfirmation = true
} else {
showingDisableConfirmation = true
}
}
)) {
Label(String(localized: "settings.icloud.enable"), systemImage: "icloud")
if cloudKitSync?.isCloudKitAvailable == false {
SettingsFormSection(footer: "settings.icloud.unavailable.footer") {
Label(String(localized: "settings.icloud.unavailable"), systemImage: "icloud.slash")
.foregroundStyle(.secondary)
}
} else {
SettingsFormSection(footer: "settings.icloud.footer") {
Toggle(isOn: Binding(
get: { settingsManager?.iCloudSyncEnabled ?? false },
set: { newValue in
if newValue {
showingEnableConfirmation = true
} else {
showingDisableConfirmation = true
}
}
)) {
Label(String(localized: "settings.icloud.enable"), systemImage: "icloud")
}
}
}
if settingsManager?.iCloudSyncEnabled == true {
syncCategoriesSection
syncStatusSection
if settingsManager?.iCloudSyncEnabled == true {
syncCategoriesSection
syncStatusSection
}
}
}
#if !os(tvOS)