realm-cocoa-converter icon indicating copy to clipboard operation
realm-cocoa-converter copied to clipboard

Crash after importing a csv file and adding a User object in realm. (iOS)

Open carlosandresSanchez opened this issue 5 years ago • 0 comments

I am importing a CSVFile in my iOS app:


let realm = try! Realm(configuration: Realm.Configuration.defaultConfiguration)
let path = Bundle.main.path(forResource: "magictelescope_csv", ofType: "csv")
let documentsPath1 = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0])
let logsPath = documentsPath1.appendingPathComponent("data")

let file = path!
let generator = ImportSchemaGenerator(file: file)
let schema = try! generator.generate()

let dataImporter = CSVDataImporter(file: file)
try! dataImporter.import(toPath: documentsPath1.absoluteString!, schema: schema)
        
        try! realm.write {
            let project = Project("Muchos")

            let dataset = Dataset()
            dataset.tableName = "magictelescope_csv"
            realm.add(dataset)
            realm.add(project)
        }

The crash log is this:

`` Terminating app due to uncaught exception 'RLMException', reason: 'Object type 'magictelescope_csv' is not managed by the Realm. If using a custom objectClasses / objectTypes array in your configuration, add magictelescope_csv to the list of objectClasses / objectTypes.' *** First throw call stack: ( 0 CoreFoundation 0x00007fff23baa1ee __exceptionPreprocess + 350 1 libobjc.A.dylib 0x00007fff50864b20 objc_exception_throw + 48 2 Realm 0x0000000104fc51ed _ZN13RLMSchemaInfoixEP8NSString + 189 3 Realm 0x0000000105019bb1 RLMAddObjectToRealm + 401 4 Realm 0x00000001050fd96b -[RLMRealm addObject:] + 43 5 RegicideDemo 0x0000000104a6733c $s12RegicideDemo15CSVDataImporterC6import6toPath6schemaSo8RLMRealmCSS_AA12ImportSchemaCtKF + 3084 6 RegicideDemo 0x0000000104a5b7ad $s12RegicideDemo14ViewControllerC10newProjectyyF + 2429 7 RegicideDemo 0x0000000104a5beea $s12RegicideDemo14ViewControllerC15newProjectClickyyypF + 58 8 RegicideDemo 0x0000000104a5bf40 $s12RegicideDemo14ViewControllerC15newProjectClickyyypFTo + 80 9 UIKitCore 0x00007fff4757a082 -[UIApplication sendAction:to:from:forEvent:] + 83 10 UIKitCore 0x00007fff46f608e5 -[UIControl sendAction:to:forEvent:] + 223 11 UIKitCore 0x00007fff46f60c2f -[UIControl _sendActionsForEvents:withEvent:] + 398 12 UIKitCore 0x00007fff46f5fb8e -[UIControl touchesEnded:withEvent:] + 481 13 UIKitCore 0x00007fff475b4a31 -[UIWindow _sendTouchesForEvent:] + 2604 14 UIKitCore 0x00007fff475b6338 -[UIWindow sendEvent:] + 4596 15 UIKitCore 0x00007fff47591693 -[UIApplication sendEvent:] + 356 16 UIKitCore 0x00007fff47611e5a __dispatchPreprocessedEventFromEventQueue + 6847 17 UIKitCore 0x00007fff47614920 __handleEventQueueInternal + 5980 18 CoreFoundation 0x00007fff23b0d271 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 19 CoreFoundation 0x00007fff23b0d19c __CFRunLoopDoSource0 + 76 20 CoreFoundation 0x00007fff23b0c974 __CFRunLoopDoSources0 + 180 21 CoreFoundation 0x00007fff23b0767f __CFRunLoopRun + 1263 22 CoreFoundation 0x00007fff23b06e66 CFRunLoopRunSpecific + 438 23 GraphicsServices 0x00007fff38346bb0 GSEventRunModal + 65 24 UIKitCore 0x00007fff47578dd0 UIApplicationMain + 1621 25 RegicideDemo 0x0000000104a6613b main + 75 26 libdyld.dylib 0x00007fff516ecd29 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

carlosandresSanchez avatar Oct 28 '19 18:10 carlosandresSanchez