I think I found a work around which is to launch the simulator first then launch Xcode then build the app. If you go the usual route your app will freeze. Also the preferences app will keep crashing at least on my system so can't sign in to test CloudKit syncing.
Post
Replies
Boosts
Views
Activity
Had this issue a while back. I had to delete all the screenshots then log out. Log back in upload the screen shots and then it seemed to work and was able to submit my app.
I figured it out. I had to build one of my old projects with iOS 14. Once the simulator came up then I rebuilt my new project in iOS 15 and it came up with no errors.
You will need to migrate your existing core data store with NSPersistentHistoryTrackingKey enabled. This will then allow your old data to be sync'd using NSPersistentCloudKitContainer.
Try deleting your Derived Data folder.
Removing your devices and connecting with lightening cable rather than WiFi.
Also you can try downloading Xcode from the developer downloads directly rather than from AppStore.
Here is how you do it:
Add this code to your AppDelegate file:
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "Your_App_CoreData_Model_Name")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
func saveContext() {
let context = persistentContainer.viewContext
if context.hasChanges {
do {
try context.save()
} catch {
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
func managedObjectContext() -> NSManagedObjectContext {
let managedObjectContext = ModelManager.instance.persistentContainer.viewContext
return managedObjectContext
}
You can get this error several different ways. If you get it during fetch requests then you should try this:
@FetchRequest(entity: NSEntityDescription.entity(forEntityName: "Your Entity Name", in: managedObjectContext), sortDescriptors: [NSSortDescriptor(key: "Your Key", ascending: true)])
In dynamic fetch requests you should try this:
var entity: Entity
var fetchRequest: FetchRequest<Your Entity>
init(_ entity: Entity) {
self.entity = entity
self.fetchRequest = FetchRequest(entity: NSEntityDescription.entity(forEntityName: "Your Entity", in: managedObjectContext), sortDescriptors: [NSSortDescriptor(key: "Your Key", ascending: true)], predicate: NSPredicate(format: "entity.uniqueIdentifier == %@", entity.uniqueIdentifier!))
}
var youEntities: FetchedResults<Your Entity> {
fetchRequest.wrappedValue
}
When creating core data objects:
let entityDescription = NSEntityDescription.entity(forEntityName: "Your Entity", in: managedObjectContext)
let object = Your Entity(entity: entityDescription!, insertInto: managedObjectContext)
Hope this helps for your Core Data with SwiftUI issues.