Post not yet marked as solved
If you are trying to access the data outside a view you need to send the modelContext as a parameter.
@Environment(\.modelContext) var modelContext
functionToPerformActionInAStructOutideYourView(modelContext)
Then in your struct
func functionToPerformActionInAStructOutideYourView(_ modelContext: ModelContext){
let possiblyAFetchRequest = FetchDescriptor<Workout>(predicate: #Predicate{ ...})
do {
try modelContext.fetch(possiblyAFetchRequest)
}
catch {}
}
Post not yet marked as solved
I have tried but as the visw isn’t yet in view setting its focus state remains false.
Post not yet marked as solved
Unfortunately no. Still very much waiting for solution. I have attempted running the code to save the data in a background thread. This does free up the UI but it then makes actually writing the data to the store take a very very long time. I would get 3 rows saved into database every second. but with 30k rows but at that rate it would take over 8 hours. Has to be a way. Can't think Apple would release something that's sooo bad especially when it should be built on top of something already tried and tested like Core Data.
Post not yet marked as solved
Are they not just "shortcuts"
Post not yet marked as solved
I just received the status back as "credited". Which basically now means wasted because my 2 for the year has just reset too. I tried to use one before my annual renewal but the "clunky" process has just meant it's been wasted lol
Post not yet marked as solved
have your tried .directory ?
Maybe could also be how you handle the
documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) cos iCloud likes to append extensions onto the expected files. I can't recall top of my head how exactly but .png would change yo something like .png.icloud
Solved. Totally forgot that URLs for file system change often so storing the full URL is pointless.
Post not yet marked as solved
Those are what get logged in the debugger. Now
"The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store."
Which i cant understand seeing as im making no changes and it was a fresh install. A close. Then a simple relaunch. This was working when I was adding all Data Models to either local storage or iCloud. Just doesn't like when i tried to separate them. Ive also deleted the records in the icloud dashboard so everything is trying to run from a clean slate.
Just so I can rule it out. Am I ok to assume that my original posted Code in first post should be able to run as expected?
Post not yet marked as solved
NSStoreModelVersionHashesDigest = "DJ2WYYwgxZ0ODDxWSCU/qENUGNTyxR4QfG8zLErpzQrvMoo9u19pSVjC7jzbUm0QLzGhFtKR3E0LRQvO9u6WXQ==";
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
"1.0.0"
);
NSStoreType = SQLite;
NSStoreUUID = "FC5CF467-5684-4C95-8C0E-49698D0A8648";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store}}, reason=Failed to open the store} with userInfo {
NSUnderlyingError = "Error Domain=NSCocoaErrorDomain Code=134100 \"The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store.\" UserInfo={metadata={\n NSPersistenceFrameworkVersion = 1337;\n NSStoreModelVersionChecksumKey = \"/mv+MJ232k6TtgLWF/6u6Xvt1IOs/ezBTew3e5ULc+E=\";\n NSStoreModelVersionHashes = {\n CloudSyncModelA = {length = 32, bytes = 0x3987992e 6ee680c6 e8bb9511 266ac8b2 ... 97ac3feb daf3a616 };\n CloudSyncModelB = {length = 32, bytes = 0xd2664c00 d176a085 d0cb6b7f 7fdd3661 ... 60f1b0b2 a9d0444e };\n CloudSyncModelC = {length = 32, bytes = 0xca91943c 6571aedb 07473eaa 154207d1 ... 66bb77c1 6283438e };\n };\n NSStoreModelVersionHashesDigest = \"DJ2WYYwgxZ0ODDxWSCU/qENUGNTyxR4QfG8zLErpzQrvMoo9u19pSVjC7jzbUm0QLzGhFtKR3E0LRQvO9u6WXQ==\";\n NSStoreModelVersionHashesVersion = 3;\n NSStoreModelVersionIdentifiers = (\n \"1.0.0\"\n );\n NSStoreType = SQLite;\n NSStoreUUID = \"FC5CF467-5684-4C95-8C0E-49698D0A8648\";\n \"_NSAutoVacuumLevel\" = 2;\n}, reason=The model used to open the store is incompatible with the one used to create the store}";
reason = "Failed to open the store";
}
CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate tearDown:]_block_invoke(806): <NSCloudKitMirroringDelegate: 0x2823704b0>: Told to tear down with reason: Store Removed
myApp/MyApp.swift:35: Fatal error: Could not create ModelContainer: SwiftDataError(_error: SwiftData.SwiftDataError._Error.loadIssueModelContainer)
Post not yet marked as solved
Well if i launch from fresh install i get
CoreData: error: Failed to stat path '/private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store', errno 2 / No such file or directory.
CoreData: error: Executing as effective user 501
CoreData: error: Failed to statfs file; errno 2 / No such file or directory.
CoreData: error: Logging status information for directory path: /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support
CoreData: error: Executing as effective user 501
CoreData: error: Information for /
CoreData: error: File Device ID: 0
CoreData: error: Device ID: 838860801
CoreData: error: File Size: 544 bytes
CoreData: error: File inode: 2
CoreData: error: File user ID: 0
CoreData: error: File group ID: 0
CoreData: error: File Permissions:
CoreData: error: d
CoreData: error: 755
CoreData: error: component is not a symbolic link
CoreData: error: component is readable
CoreData: error: component is not writeable with errno 1
CoreData: error: Information for /private
CoreData: error: File Device ID: 0
CoreData: error: Device ID: 838860801
CoreData: error: File Size: 224 bytes
CoreData: error: File inode: 1152921500312268646
CoreData: error: File user ID: 0
CoreData: error: File group ID: 0
CoreData: error: File Permissions:
CoreData: error: d
CoreData: error: 755
CoreData: error: component is not a symbolic link
CoreData: error: component is readable
CoreData: error: component is not writeable with errno 1
CoreData: error: Information for /private/var
CoreData: error: File Device ID: 0
CoreData: error: Device ID: 16777222
CoreData: error: File Size: 1152 bytes
CoreData: error: File inode: 2
CoreData: error: File user ID: 0
CoreData: error: File group ID: 0
CoreData: error: File Permissions:
CoreData: error: d
CoreData: error: 755
CoreData: error: component is not a symbolic link
CoreData: error: component is not readable with errno 1
CoreData: error: component is not writeable with errno 1
CoreData: error: Information for /private/var/mobile
CoreData: error: File Device ID: 0
CoreData: error: Device ID: 16777226
CoreData: error: File Size: 448 bytes
CoreData: error: File inode: 2
CoreData: error: File user ID: 501
CoreData: error: File group ID: 501
CoreData: error: File Permissions:
CoreData: error: d
CoreData: error: 711
CoreData: error: component is not a symbolic link
CoreData: error: component is not readable with errno 1
CoreData: error: component is not writeable with errno 1
CoreData: error: Information for /private/var/mobile/Containers
CoreData: error: File Device ID: 0
CoreData: error: Device ID: 16777226
CoreData: error: File Size: 160 bytes
CoreData: error: File inode: 45
CoreData: error: File user ID: 501
CoreData: error: File group ID: 501
CoreData: error: File Permissions:
CoreData: error: d
CoreData: error: 755
CoreData: error: component is not a symbolic link
CoreData: error: component is not readable with errno 1
CoreData: error: component is not writeable with errno 1
CoreData: error: Information for /private/var/mobile/Containers/Shared
CoreData: error: File Device ID: 0
CoreData: error: Device ID: 16777226
CoreData: error: File Size: 96 bytes
CoreData: error: File inode: 889
CoreData: error: File user ID: 0
CoreData: error: File group ID: 501
CoreData: error: File Permissions:
CoreData: error: d
CoreData: error: 755
CoreData: error: component is not a symbolic link
CoreData: error: component is not readable with errno 1
CoreData: error: component is not writeable with errno 1
CoreData: error: Information for /private/var/mobile/Containers/Shared/AppGroup
CoreData: error: File Device ID: 0
CoreData: error: Device ID: 16777226
CoreData: error: File Size: 7328 bytes
CoreData: error: File inode: 890
CoreData: error: File user ID: 501
CoreData: error: File group ID: 501
CoreData: error: File Permissions:
CoreData: error: d
CoreData: error: 755
CoreData: error: component is not a symbolic link
CoreData: error: component is not readable with errno 1
CoreData: error: component is not writeable with errno 1
CoreData: error: Information for /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027
CoreData: error: File Device ID: 0
CoreData: error: Device ID: 16777226
CoreData: error: File Size: 128 bytes
CoreData: error: File inode: 86000630
CoreData: error: File user ID: 501
CoreData: error: File group ID: 501
CoreData: error: File Permissions:
CoreData: error: d
CoreData: error: 755
CoreData: error: component is not a symbolic link
CoreData: error: component is readable
CoreData: error: component is not writeable with errno 1
CoreData: error: Information for /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library
CoreData: error: File Device ID: 0
CoreData: error: Device ID: 16777226
CoreData: error: File Size: 96 bytes
CoreData: error: File inode: 86000632
CoreData: error: File user ID: 501
CoreData: error: File group ID: 501
CoreData: error: File Permissions:
CoreData: error: d
CoreData: error: 755
CoreData: error: component is not a symbolic link
CoreData: error: component is readable
CoreData: error: component is writeable
CoreData: error: Failed to stat path '/private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support', errno 2 / No such file or directory.
CoreData: error: addPersistentStoreWithType:configuration:URL:options:error: returned error NSCocoaErrorDomain (512)
CoreData: error: userInfo:
CoreData: error: reason : Failed to create file; code = 2
CoreData: error: storeType: SQLite
CoreData: error: configuration: (null)
Post not yet marked as solved
CoreData: error: addPersistentStoreWithType:configuration:URL:options:error: returned error NSCocoaErrorDomain (134100)
CoreData: error: userInfo:
CoreData: error: metadata : {
NSPersistenceFrameworkVersion = 1337;
NSStoreModelVersionChecksumKey = "/mv+MJ232k6TtgLWF/6u6Xvt1IOs/ezBTew3e5ULc+E=";
NSStoreModelVersionHashes = {
CloudSyncModelA = {length = 32, bytes = 0x3987992e 6ee680c6 e8bb9511 266ac8b2 ... 97ac3feb daf3a616 };
CloudSyncModelB = {length = 32, bytes = 0xd2664c00 d176a085 d0cb6b7f 7fdd3661 ... 60f1b0b2 a9d0444e };
CloudSyncModelC = {length = 32, bytes = 0xca91943c 6571aedb 07473eaa 154207d1 ... 66bb77c1 6283438e };
};
NSStoreModelVersionHashesDigest = "DJ2WYYwgxZ0ODDxWSCU/qENUGNTyxR4QfG8zLErpzQrvMoo9u19pSVjC7jzbUm0QLzGhFtKR3E0LRQvO9u6WXQ==";
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
"1.0.0"
);
NSStoreType = SQLite;
NSStoreUUID = "FC5CF467-5684-4C95-8C0E-49698D0A8648";
"_NSAutoVacuumLevel" = 2;
}
CoreData: error: reason : The model used to open the store is incompatible with the one used to create the store
CoreData: error: storeType: SQLite
CoreData: error: configuration: (null)
CoreData: error: URL: file:///private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application%20Support/default.store
CoreData: error: addPersistentStoreWithType:configuration:URL:options:error: returned error NSCocoaErrorDomain (134110)
CoreData: error: userInfo:
CoreData: error: NSUnderlyingError : Error Domain=NSCocoaErrorDomain Code=134100 "The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store." UserInfo={metadata={
NSPersistenceFrameworkVersion = 1337;
NSStoreModelVersionChecksumKey = "/mv+MJ232k6TtgLWF/6u6Xvt1IOs/ezBTew3e5ULc+E=";
NSStoreModelVersionHashes = {
CloudSyncModelA = {length = 32, bytes = 0x3987992e 6ee680c6 e8bb9511 266ac8b2 ... 97ac3feb daf3a616 };
CloudSyncModelB = {length = 32, bytes = 0xd2664c00 d176a085 d0cb6b7f 7fdd3661 ... 60f1b0b2 a9d0444e };
CloudSyncModelC = {length = 32, bytes = 0xca91943c 6571aedb 07473eaa 154207d1 ... 66bb77c1 6283438e };
};
NSStoreModelVersionHashesDigest = "DJ2WYYwgxZ0ODDxWSCU/qENUGNTyxR4QfG8zLErpzQrvMoo9u19pSVjC7jzbUm0QLzGhFtKR3E0LRQvO9u6WXQ==";
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
"1.0.0"
);
NSStoreType = SQLite;
NSStoreUUID = "FC5CF467-5684-4C95-8C0E-49698D0A8648";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store}
CoreData: error: reason : Failed to open the store
CoreData: error: storeType: SQLite
CoreData: error: configuration: (null)
CoreData: error: URL: file:///private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application%20Support/default.store
CoreData: error: <NSPersistentStoreCoordinator: 0x2837713b0>: Attempting recovery from error encountered during addPersistentStore: 0x28121c2a0 Error Domain=NSCocoaErrorDomain Code=134110 "An error occurred during persistent store migration." UserInfo={NSUnderlyingError=0x2812cca50 {Error Domain=NSCocoaErrorDomain Code=134100 "The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store." UserInfo={metadata={
NSPersistenceFrameworkVersion = 1337;
NSStoreModelVersionChecksumKey = "/mv+MJ232k6TtgLWF/6u6Xvt1IOs/ezBTew3e5ULc+E=";
NSStoreModelVersionHashes = {
CloudSyncModelA = {length = 32, bytes = 0x3987992e 6ee680c6 e8bb9511 266ac8b2 ... 97ac3feb daf3a616 };
CloudSyncModelB = {length = 32, bytes = 0xd2664c00 d176a085 d0cb6b7f 7fdd3661 ... 60f1b0b2 a9d0444e };
CloudSyncModelC = {length = 32, bytes = 0xca91943c 6571aedb 07473eaa 154207d1 ... 66bb77c1 6283438e };
};
NSStoreModelVersionHashesDigest = "DJ2WYYwgxZ0ODDxWSCU/qENUGNTyxR4QfG8zLErpzQrvMoo9u19pSVjC7jzbUm0QLzGhFtKR3E0LRQvO9u6WXQ==";
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
"1.0.0"
);
NSStoreType = SQLite;
NSStoreUUID = "FC5CF467-5684-4C95-8C0E-49698D0A8648";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store}}, reason=Failed to open the store}
CoreData: error: Store failed to load. <NSPersistentStoreDescription: 0x28121c7e0> (type: SQLite, url: file:///private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application%20Support/default.store) with error = Error Domain=NSCocoaErrorDomain Code=134110 "An error occurred during persistent store migration." UserInfo={NSUnderlyingError=0x2812cca50 {Error Domain=NSCocoaErrorDomain Code=134100 "The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store." UserInfo={metadata={
NSPersistenceFrameworkVersion = 1337;
NSStoreModelVersionChecksumKey = "/mv+MJ232k6TtgLWF/6u6Xvt1IOs/ezBTew3e5ULc+E=";
NSStoreModelVersionHashes = {
CloudSyncModelA = {length = 32, bytes = 0x3987992e 6ee680c6 e8bb9511 266ac8b2 ... 97ac3feb daf3a616 };
CloudSyncModelB = {length = 32, bytes = 0xd2664c00 d176a085 d0cb6b7f 7fdd3661 ... 60f1b0b2 a9d0444e };
CloudSyncModelC = {length = 32, bytes = 0xca91943c 6571aedb 07473eaa 154207d1 ... 66bb77c1 6283438e };
};
Post not yet marked as solved
CoreData: error: URL: file:///private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application%20Support/default.store
CoreData: error: <NSPersistentStoreCoordinator: 0x281ab0700>: Attempting recovery from error encountered during addPersistentStore: 0x283fe4030 Error Domain=NSCocoaErrorDomain Code=512 "The file couldn’t be saved." UserInfo={reason=Failed to create file; code = 2}
CoreData: error: During recovery, parent directory path reported as missing
CoreData: error: Recovery attempt while adding <NSPersistentStoreDescription: 0x283fe4030> (type: SQLite, url: file:///private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application%20Support/default.store) was successful!
CoreData: error: Could not materialize Objective-C class named "Array" from declared attribute value type "Array<Data>" of attribute named images
CoreData: error: (1) I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA'
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLFetchRequestContext: 0x28089ae60> , I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA' with userInfo of {
NSFilePath = "/private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store";
NSSQLiteErrorDomain = 1;
}
CoreData: error: -executeRequest: encountered exception = I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA' with userInfo = {
NSFilePath = "/private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store";
NSSQLiteErrorDomain = 1;
}
CoreData: error: (1) I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA'
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLFetchRequestContext: 0x28089ae60> , I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA' with userInfo of {
NSFilePath = "/private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store";
NSSQLiteErrorDomain = 1;
}
CoreData: error: -executeRequest: encountered exception = I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA' with userInfo = {
NSFilePath = "/private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store";
NSSQLiteErrorDomain = 1;
}
CoreData: error: (1) I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA'
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLFetchRequestContext: 0x28089ae60> , I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA' with userInfo of {
NSFilePath = "/private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store";
NSSQLiteErrorDomain = 1;
}
CoreData: error: -executeRequest: encountered exception = I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA' with userInfo = {
NSFilePath = "/private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store";
NSSQLiteErrorDomain = 1;
}
CoreData: error: (1) I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA'
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLFetchRequestContext: 0x28089ae60> , I/O error for database at /private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store. SQLite error code:1, 'no such table: ZCLOUDSYNCMODELA' with userInfo of {
NSFilePath = "/private/var/mobile/Containers/Shared/AppGroup/98EF0668-1D20-4B71-967F-E5D8F9FB3027/Library/Application Support/default.store";
NSSQLiteErrorDomain = 1;
}
repeats for 40 blocks complaining about all the data Models i'm wanting to add to icloud and not the "default.store"
I have found installing the swift algorithms package gives a .uniqued(on: \.keyPath) method that can be applied to an array.
Post not yet marked as solved
guard let appSupportDir = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).last else { return }
all 3 files for the SQL storage is located here at least on iOS
Post not yet marked as solved
So I just added more RAM. Was on 8gb and added another 32gb to make it 40gb. The simulator now at least loads but still a slow process but under 5 mins to launch as apposed to the +30 mins to infinity I was having to wait. Preview still doesn't work so not a fix adding more memory just a step in the right direction it seems.