Fix iOS build errors and test app setup
- Fix async/await usage in background fetch handler - Fix Core Data metadata access errors - Replace SQLITE_TRANSIENT with nil for Swift compatibility - Fix PermissionStatus interface and type casts in test app - Add iOS setup documentation to BUILDING.md - Update iOS sync workflow to handle Podfile regeneration Resolves all iOS compilation errors and improves test app setup process.
This commit is contained in:
@@ -261,17 +261,8 @@ class PersistenceController {
|
||||
description?.shouldMigrateStoreAutomatically = true
|
||||
description?.shouldInferMappingModelAutomatically = true
|
||||
|
||||
// Set initial schema version metadata (for new stores)
|
||||
if !inMemory {
|
||||
var metadata = description?.metadata ?? [:]
|
||||
if metadata["schema_version"] == nil {
|
||||
metadata["schema_version"] = PersistenceController.SCHEMA_VERSION
|
||||
description?.metadata = metadata
|
||||
}
|
||||
}
|
||||
|
||||
var loadError: Error? = nil
|
||||
tempContainer?.loadPersistentStores { description, error in
|
||||
tempContainer?.loadPersistentStores { storeDescription, error in
|
||||
if let error = error as NSError? {
|
||||
loadError = error
|
||||
print("DNP-PLUGIN: CoreData store load error: \(error.localizedDescription)")
|
||||
@@ -281,7 +272,19 @@ class PersistenceController {
|
||||
}
|
||||
} else {
|
||||
print("DNP-PLUGIN: CoreData store loaded successfully")
|
||||
print("DNP-PLUGIN: Store URL: \(description.url?.absoluteString ?? "unknown")")
|
||||
print("DNP-PLUGIN: Store URL: \(storeDescription.url?.absoluteString ?? "unknown")")
|
||||
|
||||
// Set initial schema version metadata (for new stores)
|
||||
// Metadata must be set using the coordinator after the store is loaded
|
||||
if !inMemory,
|
||||
let coordinator = tempContainer?.persistentStoreCoordinator,
|
||||
let store = coordinator.persistentStores.first,
|
||||
let metadata = store.metadata,
|
||||
metadata["schema_version"] == nil {
|
||||
var newMetadata = metadata
|
||||
newMetadata["schema_version"] = PersistenceController.SCHEMA_VERSION
|
||||
coordinator.setMetadata(newMetadata, for: store)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,7 +376,13 @@ class PersistenceController {
|
||||
return
|
||||
}
|
||||
|
||||
let currentVersion = store.metadata["schema_version"] as? Int ?? 1
|
||||
// store.metadata is optional, so we need to unwrap it
|
||||
guard let metadata = store.metadata else {
|
||||
print("DNP-PLUGIN: Store metadata is nil, using default schema version")
|
||||
return
|
||||
}
|
||||
|
||||
let currentVersion = metadata["schema_version"] as? Int ?? 1
|
||||
let expectedVersion = PersistenceController.SCHEMA_VERSION
|
||||
|
||||
if currentVersion != expectedVersion {
|
||||
@@ -381,9 +390,13 @@ class PersistenceController {
|
||||
print("DNP-PLUGIN: CoreData auto-migration will handle schema changes")
|
||||
|
||||
// Update metadata for future reference (does not trigger migration)
|
||||
var metadata = store.metadata
|
||||
metadata["schema_version"] = expectedVersion
|
||||
// Note: Metadata persists on next store save
|
||||
// Use the coordinator to set metadata
|
||||
if let coordinator = container?.persistentStoreCoordinator {
|
||||
var newMetadata = metadata
|
||||
newMetadata["schema_version"] = expectedVersion
|
||||
coordinator.setMetadata(newMetadata, for: store)
|
||||
// Note: Metadata persists on next store save
|
||||
}
|
||||
} else {
|
||||
print("DNP-PLUGIN: Schema version verified: \(currentVersion)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user