Debug helper: initializeCloudKitSchema (opt-in por launch arg -InitializeCloudKitSchema)
Materializa el modelo completo en el esquema de Development de CloudKit para poder desplegar a Production los campos que nunca se exportaron (monthlyContribution, allocationTarget). Sin ellos, Production rechaza los registros y el export falla en bloque (CKErrorPartialFailure). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LZFmGhbWzibhApev3C4554
This commit is contained in:
@@ -192,6 +192,24 @@ class CoreDataStack: ObservableObject {
|
||||
print("Core Data failed to load: \(error), \(error.userInfo)")
|
||||
} else {
|
||||
print("Core Data loaded successfully at: \(description.url?.path ?? "unknown")")
|
||||
#if DEBUG
|
||||
// Dev-only, opt-in: push the FULL model schema to the Development CloudKit
|
||||
// environment so optional fields that were never exported by a Debug run
|
||||
// (e.g. monthlyContribution on InvestmentSource, allocationTarget on Category)
|
||||
// get materialised — otherwise they can't be deployed to Production and every
|
||||
// Production export rejects those records (bare CKErrorPartialFailure).
|
||||
// Run ONCE from Xcode with launch arg -InitializeCloudKitSchema, watch for the
|
||||
// ✅ log, then deploy to Production in the CloudKit Console and remove the arg.
|
||||
if ProcessInfo.processInfo.arguments.contains("-InitializeCloudKitSchema"),
|
||||
let ckContainer = container as? NSPersistentCloudKitContainer {
|
||||
do {
|
||||
try ckContainer.initializeCloudKitSchema(options: [])
|
||||
print("✅ CloudKit schema initialized in Development. Now open the CloudKit Console → Deploy Schema Changes → Production.")
|
||||
} catch {
|
||||
print("❌ initializeCloudKitSchema failed: \(error)")
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
self?.isLoaded = true
|
||||
|
||||
Reference in New Issue
Block a user