Saturday, November 7, 2026
HomeiOS Developmentios - Error within the Xcode terminal whereas doing coredata?

ios – Error within the Xcode terminal whereas doing coredata?

[ad_1]

I bought this entity

enter image description here

understanding that some strings are picker and transformed to string like pickerselectionfromRoad

I bought this persistence controller:

import CoreData

struct PersistenceController {
    static let shared = PersistenceController()
    static var preview: PersistenceController = {
        let outcome = PersistenceController(inMemory: true)
        let viewContext = outcome.container.viewContext
        for _ in 0..<10 {
            let newItem = Merchandise(context: viewContext)
            newItem.selectedVehicle = "car"
            newItem.tripDate = Date()
            newItem.selectedSpace = "house"
            newItem.pickerSelectionfromRoad = "from"
            newItem.pickerSelectiontoRoad = "to"
            newItem.departureTime = Date()
            newItem.arrivalTime = Date()
            newItem.extraCharge = "cost"
            newItem.extraWeight = "weight"
            newItem.extraInfo = "information"
            
        }
        do {
            attempt viewContext.save()
        } catch {
            // Change this implementation with code to deal with the error appropriately.
            // fatalError() causes the applying to generate a crash log and terminate. You shouldn't use this operate in a delivery utility, though it might be helpful throughout growth.
            let nsError = error as NSError
            fatalError("Unresolved error (nsError), (nsError.userInfo)")
        }
        return outcome
    }()

    let container: NSPersistentContainer

    init(inMemory: Bool = false) {
        container = NSPersistentContainer(title: "MyProject")
        if inMemory {
            container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
        }
        container.viewContext.automaticallyMergesChangesFromParent = true
        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            if let error = error as NSError? {
                // Change this implementation with code to deal with the error appropriately.
                // fatalError() causes the applying to generate a crash log and terminate. You shouldn't use this operate in a delivery utility, though it might be helpful throughout growth.

                /*
                Typical causes for an error right here embody:
                * The dad or mum listing doesn't exist, can't be created, or disallows writing.
                * The persistent retailer is just not accessible, resulting from permissions or knowledge safety when the system is locked.
                * The system is out of house.
                * The shop couldn't be migrated to the present mannequin model.
                Verify the error message to find out what the precise drawback was.
                */
                fatalError("Unresolved error (error), (error.userInfo)")
            }
        })
    }
}

and I bought this test2 view the place I wish to place my knowledge in an inventory

import SwiftUI
import CoreData


struct Test2: View {
    @Atmosphere(.managedObjectContext) personal var viewContext

        @FetchRequest(
            sortDescriptors: [NSSortDescriptor(keyPath: Item.pickerSelectionfromRoad, ascending: true)],
            animation: .default)
        personal var objects: FetchedResults<Merchandise>

        var physique: some View {
            NavigationView {
                Listing {
                    ForEach(objects) { merchandise in
                        NavigationLink {
                            Textual content("Merchandise at (merchandise.tripDate!, formatter: itemFormatter)")
                        } label: {
                            Textual content(merchandise.tripDate!, formatter: itemFormatter)
                            Textual content(merchandise.pickerSelectiontoRoad!)
                            Textual content(merchandise.pickerSelectionfromRoad!)
                        }
                    }
                    .onDelete(carry out: deleteItems)
                }
                .toolbar {
                    ToolbarItem(placement: .navigationBarTrailing) {
                        EditButton()
                    }
                }
                Textual content("Choose an merchandise")
            }
        }

        personal func addItem() {
            withAnimation {
                let newItem = Merchandise(context: viewContext)
                newItem.selectedVehicle = String()
                newItem.tripDate = Date()
                newItem.selectedSpace = String()
                newItem.pickerSelectionfromRoad = String()
                newItem.pickerSelectiontoRoad = String()
                newItem.departureTime = Date()
                newItem.arrivalTime = Date()
                newItem.extraCharge = String()
                newItem.extraWeight = String()
                newItem.extraInfo = String()

                do {
                    attempt viewContext.save()
                } catch {
                    // Change this implementation with code to deal with the error appropriately.
                    // fatalError() causes the applying to generate a crash log and terminate. You shouldn't use this operate in a delivery utility, though it might be helpful throughout growth.
                    let nsError = error as NSError
                    fatalError("Unresolved error (nsError), (nsError.userInfo)")
                }
            }
        }

        personal func deleteItems(offsets: IndexSet) {
            withAnimation {
                offsets.map { objects[$0] }.forEach(viewContext.delete)

                do {
                    attempt viewContext.save()
                } catch {
                    // Change this implementation with code to deal with the error appropriately.
                    // fatalError() causes the applying to generate a crash log and terminate. You shouldn't use this operate in a delivery utility, though it might be helpful throughout growth.
                    let nsError = error as NSError
                    fatalError("Unresolved error (nsError), (nsError.userInfo)")
                }
            }
        }
    }

    personal let itemFormatter: DateFormatter = {
        let formatter = DateFormatter()
        formatter.dateStyle = .brief
        formatter.timeStyle = .medium
        return formatter
    }()

struct Test_Previews: PreviewProvider {
    static var previews: some View {
        Check().setting(.managedObjectContext, PersistenceController.preview.container.viewContext)

    }
}

I would like the button in one other test1 view to do the add course of in an inventory to test2 view passing additionally test2 these variables

struct Test1: View {
@Atmosphere(.managedObjectContext) personal var viewContext
@FetchRequest(sortDescriptors: []) var objects: FetchedResults<Merchandise>
 let variable = Test2()
    var physique: some View{
        
                                     Button(motion: {
                                         self.variable.addItem()
                                     }) {
                                             Textual content("Submit")
                                                 .font(.system(measurement: 17))
                                                 .fontWeight(.daring)
                                                 .foregroundColor(.white)
                                                 .padding()
                                                 .background(
                                                     RoundedRectangle(cornerRadius: 25)
                                                         .fill(Colour("Colour"))
                                                         .shadow(shade: .grey, radius: 2, x: 0, y: 2)
                                           
                                                 )
                                             
                                        
                                     }
    }
}


struct Test1_Previews: PreviewProvider {
    static var previews: some View {
        Test1().setting(.managedObjectContext, PersistenceController.preview.container.viewContext)

    }
}

however in any case this difficult work I find yourself having the issue right here in my terminal that error

2022-03-05 19:41:26.375211+0200 MyProject[30774:285444] [error] warning:  View context accessed for persistent container MyProject with no shops loaded
CoreData: warning:  View context accessed for persistent container MyProject with no shops loaded
2022-03-05 19:41:26.577667+0200 MyProject[30774:285444] [error] error: addPersistentStoreWithType:configuration:URL:choices:error: returned error NSCocoaErrorDomain (134140)
CoreData: error: addPersistentStoreWithType:configuration:URL:choices:error: returned error NSCocoaErrorDomain (134140)
CoreData: annotation: userInfo:
CoreData: annotation:   destinationModel : (<NSManagedObjectModel: 0x6000005de260>) isEditable 0, entities {
    Merchandise = "(<NSEntityDescription: 0x6000011fc840>) title Merchandise, managedObjectClassName Merchandise, renamingIdentifier Merchandise, isAbstract 0, superentity title (null), properties {n    arrivalTime = "(<NSAttributeDescription: 0x6000008fb600>), title arrivalTime, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier arrivalTime, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    departureTime = "(<NSAttributeDescription: 0x6000008fb680>), title departureTime, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier departureTime, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    extraCharge = "(<NSAttributeDescription: 0x6000008fb700>), title extraCharge, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier extraCharge, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    extraInfo = "(<NSAttributeDescription: 0x6000008fb780>), title extraInfo, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier extraInfo, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    extraWeight = "(<NSAttributeDescription: 0x6000008fb800>), title extraWeight, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier extraWeight, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    pickerSelectionfromRoad = "(<NSAttributeDescription: 0x6000008fb880>), title pickerSelectionfromRoad, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier pickerSelectionfromRoad, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    pickerSelectiontoRoad = "(<NSAttributeDescription: 0x6000008fb900>), title pickerSelectiontoRoad, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier pickerSelectiontoRoad, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    selectedSpace = "(<NSAttributeDescription: 0x6000008fb980>), title selectedSpace, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier selectedSpace, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    selectedVehicle = "(<NSAttributeDescription: 0x6000008fba00>), title selectedVehicle, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier selectedVehicle, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    tripDate = "(<NSAttributeDescription: 0x6000008fba80>), title tripDate, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier tripDate, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n}, subentities {n}, userInfo {n}, versionHashModifier (null), uniquenessConstraints (n)";
}, fetch request templates {
}
CoreData: annotation:   sourceModel : (<NSManagedObjectModel: 0x6000005fcb40>) isEditable 0, entities {
    Merchandise = "(<NSEntityDescription: 0x6000011fcd10>) title Merchandise, managedObjectClassName NSManagedObject, renamingIdentifier Merchandise, isAbstract 0, superentity title (null), properties {n    arrivalTime = "(<NSAttributeDescription: 0x6000008ed400>), title arrivalTime, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier arrivalTime, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    departureTime = "(<NSAttributeDescription: 0x6000008ed380>), title departureTime, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier departureTime, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    extraCharge = "(<NSAttributeDescription: 0x6000008ed800>), title extraCharge, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier extraCharge, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 200 , attributeValueClassName NSNumber, defaultValue 0, preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    extraInfo = "(<NSAttributeDescription: 0x6000008ed780>), title extraInfo, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier extraInfo, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    extraWeight = "(<NSAttributeDescription: 0x6000008ed300>), title extraWeight, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier extraWeight, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 200 , attributeValueClassName NSNumber, defaultValue 0, preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    id = "(<NSAttributeDescription: 0x6000008ed480>), title id, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier id, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 1100 , attributeValueClassName NSUUID, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    pickerSelectionfromRoad = "(<NSAttributeDescription: 0x6000008ed700>), title pickerSelectionfromRoad, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier pickerSelectionfromRoad, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    pickerSelectiontoRoad = "(<NSAttributeDescription: 0x6000008ed500>), title pickerSelectiontoRoad, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier pickerSelectiontoRoad, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    selectedSpace = "(<NSAttributeDescription: 0x6000008ed580>), title selectedSpace, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier selectedSpace, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    selectedVehicle = "(<NSAttributeDescription: 0x6000008ed600>), title selectedVehicle, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier selectedVehicle, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n    tripDate = "(<NSAttributeDescription: 0x6000008ed680>), title tripDate, isOptional 1, isTransient 0, entity Merchandise, renamingIdentifier tripDate, validation predicates (n), warnings (n), versionHashModifier (null)n userInfo {n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null), preservesValueInHistoryOnDeletion NO, allowsCloudEncryption NO";n}, subentities {n}, userInfo {n}, versionHashModifier (null), uniquenessConstraints (n)";
}, fetch request templates {
}
CoreData: annotation:   motive : Cannot discover mapping mannequin for migration
CoreData: annotation: storeType: SQLite
CoreData: annotation: configuration: (null)
CoreData: annotation: URL: file:///Customers/consumer/Library/Developer/CoreSimulator/Gadgets/F1494E7C-CD8A-4151-8BDC-667933BB7D43/knowledge/Containers/Knowledge/Software/BB2F4DE6-F7BF-4093-B891-672021F99982/Library/Applicationpercent20Support/MyProject.sqlite
CoreData: annotation: choices:
CoreData: annotation:   NSInferMappingModelAutomaticallyOption : 1
CoreData: annotation:   NSMigratePersistentStoresAutomaticallyOption : 1
CoreData: annotation: <NSPersistentStoreCoordinator: 0x600000dfe840>: Trying restoration from error encountered throughout addPersistentStore: Error Area=NSCocoaErrorDomain Code=134140 "Persistent retailer migration failed, lacking mapping mannequin." UserInfo={destinationModel=(<NSManagedObjectModel: 0x6000005de260>) isEditable 0, entities {
    
}, fetch request templates {
}, motive=Cannot discover mapping mannequin for migration}
MyProject/Persistence.swift:61: Deadly error: Unresolved error Error Area=NSCocoaErrorDomain Code=134140 "Persistent retailer migration failed, lacking mapping mannequin." UserInfo={destinationModel=(<NSManagedObjectModel: 0x6000005de260>) isEditable 0, entities {
  
}, fetch request templates {
}, motive=Cannot discover mapping mannequin for migration}, ["sourceModel": (<NSManagedObjectModel: 0x6000005fcb40>) isEditable 0, entities {

}, fetch request templates {
}, "reason": Can't find mapping model for migration, "destinationModel": (<NSManagedObjectModel: 0x6000005de260>) isEditable 0, entities {
  
}, fetch request templates {
}]
2022-03-05 19:41:26.606803+0200 MyProject[30774:285444] Space_Book/Persistence.swift:61: Deadly error: Unresolved error Error Area=NSCocoaErrorDomain Code=134140 "Persistent retailer migration failed, lacking mapping mannequin." UserInfo={destinationModel=(<NSManagedObjectModel: 0x6000005de260>) isEditable 0, entities {
    
}, fetch request templates {
}, motive=Cannot discover mapping mannequin for migration}, ["sourceModel": (<NSManagedObjectModel: 0x6000005fcb40>) isEditable 0, entities {
   
}, fetch request templates {
}, "reason": Can't find mapping model for migration, "destinationModel": 
}, fetch request templates {
}]

enter image description here

Please I wish to know what precipitated this drawback as a result of my work stopped not too long ago due to it !

Thanks very a lot !!

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments