Use production CloudKit environment for Xcode builds

Development-signed builds now opt into the Production CloudKit
environment via com.apple.developer.icloud-container-environment,
driven by a CLOUDKIT_ENV build setting. A new Debug-CKDev configuration
and "Yattee (CloudKit Dev)" scheme switch to the Development
environment for schema work.

The DEV badge and banner in iCloud settings now reflect the actual
environment (YatteeCloudKitEnvironment Info.plist key) instead of
#if DEBUG, and the sync engine logs the environment at startup.
This commit is contained in:
Arkadiusz Fal
2026-10-23 21:47:34 +02:00
parent c60f483d3c
commit 2a49a5db68
11 changed files with 388 additions and 28 deletions

View File

@@ -12,6 +12,17 @@ enum AppIdentifiers {
"iCloud.\(bundleIdentifier)"
}
/// CloudKit environment this build is signed for ("Development" or "Production"),
/// from the `CLOUDKIT_ENV` build setting. Debug builds use Production unless
/// built with the Debug-CKDev configuration ("Yattee (CloudKit Dev)" scheme).
static var iCloudEnvironment: String {
Bundle.main.object(forInfoDictionaryKey: "YatteeCloudKitEnvironment") as? String ?? "Production"
}
static var isCloudKitDevelopmentEnvironment: Bool {
iCloudEnvironment == "Development"
}
// MARK: - Background Tasks
static var backgroundFeedRefresh: String {

View File

@@ -37,6 +37,8 @@
<array>
<string>stream.yattee.app.activity</string>
</array>
<key>YatteeCloudKitEnvironment</key>
<string>$(CLOUDKIT_ENV)</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>

View File

@@ -46,6 +46,8 @@
<array>
<string>stream.yattee.app.activity</string>
</array>
<key>YatteeCloudKitEnvironment</key>
<string>$(CLOUDKIT_ENV)</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>

View File

@@ -13673,7 +13673,6 @@
}
},
"settings.icloud.dev.badge" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
@@ -13684,7 +13683,6 @@
}
},
"settings.icloud.dev.footer" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
@@ -13695,7 +13693,6 @@
}
},
"settings.icloud.dev.title" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {

View File

@@ -311,6 +311,7 @@ final class CloudKitSyncEngine: @unchecked Sendable {
self.container = container
self.database = database
self.zoneManager = CloudKitZoneManager(database: database)
LoggingService.shared.logCloudKit("CloudKit environment: \(AppIdentifiers.iCloudEnvironment)")
} else {
LoggingService.shared.logCloudKit("iCloud container entitlement missing (re-signed build) - CloudKit sync unavailable")
self.container = nil

View File

@@ -167,15 +167,15 @@ struct SettingsView: View {
} label: {
HStack {
Label(String(localized: "settings.icloud.title"), systemImage: "icloud")
#if DEBUG
Spacer()
Text(String(localized: "settings.icloud.dev.badge"))
.font(.caption2.bold())
.foregroundStyle(.white)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(.orange, in: Capsule())
#endif
if AppIdentifiers.isCloudKitDevelopmentEnvironment {
Spacer()
Text(String(localized: "settings.icloud.dev.badge"))
.font(.caption2.bold())
.foregroundStyle(.white)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(.orange, in: Capsule())
}
}
}
@@ -287,15 +287,15 @@ struct SettingsView: View {
} label: {
HStack {
Label(String(localized: "settings.icloud.title"), systemImage: "icloud")
#if DEBUG
Spacer()
Text(String(localized: "settings.icloud.dev.badge"))
.font(.caption2.bold())
.foregroundStyle(.white)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(.orange, in: Capsule())
#endif
if AppIdentifiers.isCloudKitDevelopmentEnvironment {
Spacer()
Text(String(localized: "settings.icloud.dev.badge"))
.font(.caption2.bold())
.foregroundStyle(.white)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(.orange, in: Capsule())
}
}
}

View File

@@ -50,13 +50,13 @@ struct iCloudSettingsView: View {
var body: some View {
SettingsFormContainer {
#if DEBUG
SettingsFormSection(footer: "settings.icloud.dev.footer") {
Label(String(localized: "settings.icloud.dev.title"), systemImage: "hammer.fill")
.foregroundStyle(.orange)
.font(.subheadline)
if AppIdentifiers.isCloudKitDevelopmentEnvironment {
SettingsFormSection(footer: "settings.icloud.dev.footer") {
Label(String(localized: "settings.icloud.dev.title"), systemImage: "hammer.fill")
.foregroundStyle(.orange)
.font(.subheadline)
}
}
#endif
if cloudKitSync?.isCloudKitAvailable == false {
SettingsFormSection(footer: "settings.icloud.unavailable.footer") {

View File

@@ -4,6 +4,8 @@
<dict>
<key>com.apple.developer.aps-environment</key>
<string>production</string>
<key>com.apple.developer.icloud-container-environment</key>
<string>$(CLOUDKIT_ENV)</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.$(CFBundleIdentifier)</string>

View File

@@ -4,6 +4,8 @@
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.icloud-container-environment</key>
<string>$(CLOUDKIT_ENV)</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.$(CFBundleIdentifier)</string>