realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.28k stars 2.14k forks source link

Crash: Realm file decryption failed Path #6948

Closed fvvliet closed 3 years ago

fvvliet commented 3 years ago

Goals

Run Realm without crashes on iOS 14

Expected Results

Open Realm database without issues

Actual Results

Crash: "Realm file decryption failed Path"

Steps for others to Reproduce

Use Realm older version (version 4.x), run app and fill database with some data, update to Realm 10.1.4, run app again

Code Sample

    do {
        try Realm.Configuration.defaultConfiguration = configuration()

        RealmManager.shared.realm = try Realm()

        if debugLogging {
            log.info("Realm database: \(String(describing: Realm.Configuration.defaultConfiguration.fileURL))")
            log.info("Realm encryptionkey: \(encryptionKey()), Hex encode first to use it.")
        }

        return true

    } catch {
        log.error(error)
        return false
    }

Version of Realm and Tooling

Realm framework version: v 10.1.4

Realm Object Server version: ?

Xcode version: 12.1

iOS/OSX version: 14.1

Dependency manager + version: Cocoapods 1.10

jsflax commented 3 years ago

Hey, can you send us the full stack trace please? Thanks.

fvvliet commented 3 years ago

2020-11-19 16:12:57.412537+0100 OLVG Pijn App[7936:2716324] [AppCenterCrashes] WARNING: -[MSCrashes configureCrashReporterWithUncaughtExceptionHandlerEnabled:]/648 Detecting crashes is NOT enabled due to running the app with a debugger attached. 2020-11-19 16:12:57.430246+0100 OLVG Pijn App[7936:2716553] [Client] Updating selectors after delegate removal failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 89 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 89 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.} 2020-11-19 16:12:57.431141+0100 OLVG Pijn App[7936:2716324] [AppCenter] WARNING: -[MSAuthTokenContext authTokenHistory]/210 Failed to retrieve history state or none was found. 2020-11-19 16:12:57.431195+0100 OLVG Pijn App[7936:2716324] [AppCenter] WARNING: -[MSAuthTokenContext setAuthTokenHistory:]/225 Failed to save new history state. 16:12:57.592 ❤️ ERROR RealmManager.initializeModel():40 - Error Domain=io.realm Code=2 "Unable to open a realm at path '/var/mobile/Containers/Data/Application/6D9776FD-9ABE-4C20-A993-1003567246FA/Documents/default.realm': Realm file decryption failed Path:Exception backtrace: 0 Realm 0x00000001019cd950 _ZN5realm15InvalidDatabaseC2ERKNSt3112basic_stringIcNS1_11char_traitsIcEENS19allocatorIcEEEES9 + 60 1 Realm 0x000000010199db7c _ZN5realm9SlabAlloc11attach_fileERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS0_6ConfigE + 2852 2 Realm 0x00000001019cfa10 _ZN5realm2DB7do_openERKNSt3112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbbNS_9DBOptionsE + 3156 3 Realm 0x00000001019d2490 _ZN5realm2DB4openERNS_11ReplicationENS_9DBOptionsE + 244 4 Realm 0x00000001019d6f78 _ZN5realm2DB6createERNS_11ReplicationENS_9DBOptionsE + 392 5 Realm 0x000000010141216c _ZN5realm5_impl16RealmCoordinator7open_dbEv + 992 6 Realm 0x0000000101411374 _ZN5realm5_impl16RealmCoordinator12do_get_realmENS_5Realm6ConfigERNSt3110shared_ptrIS2_EENS_4util8OptionalINS_9VersionIDEEERNS8_17CheckedUniqueLockE + 68 7 Realm 0x0000000101411190 _ZN5realm5_impl16RealmCoordinator9get_realmENS_5Realm6ConfigENS_4util8OptionalINS_9VersionIDEEE + 668 8 Realm 0x00000001016da470 _ZN5realm5Realm16get_shared_realmENS0_6ConfigE + 176 9 Realm 0x0000000101644704 +[RLMRealm realmWithConfiguration:queue:error:] + 1796 10 RealmSwift 0x00000001032ff6ac $sSo8RLMRealmC13configuration5queueABSo0A13ConfigurationC_So012OS_dispatch_C0CSgtKcfCTO + 156 11 RealmSwift 0x000000010335dd7c $s10RealmSwift0A0V5queueACSo012OS_dispatch_C0CSg_tKcfC + 152 12 OLVG Pijn App 0x000000010081ccd0 $s13OLVG_Pijn_App12RealmManagerC15initializeModelSbyFZ + 380 13 OLVG Pijn App 0x0000000100819b30 $s13OLVG_Pijn_App0C8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtF + 448 14 OLVG Pijn App 0x000000010081a0c4 $s13OLVG_Pijn_App0C8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtFTo + 212 15 UIKitCore 0x00000001b4234120 B718818B-0B80-3807-83BF-BB4FD626F70C + 11657504 16 UIKitCore 0x00000001b42360c0 B718818B-0B80-3807-83BF-BB4FD626F70C + 11665600 17 UIKitCore 0x00000001b423b874 B718818B-0B80-3807-83BF-BB4FD626F70C + 11688052 18 UIKitCore 0x00000001b39196f0 B718818B-0B80-3807-83BF-BB4FD626F70C + 2111216 19 UIKitCore 0x00000001b3e3cb78 _UIScenePerformActionsWithLifecycleActionMask + 100 20 UIKitCore 0x00000001b391a1d8 B718818B-0B80-3807-83BF-BB4FD626F70C + 2114008 21 UIKitCore 0x00000001b3919ce0 B718818B-0B80-3807-83BF-BB4FD626F70C + 2112736 22 UIKitCore 0x00000001b391a004 B718818B-0B80-3807-83BF-BB4FD626F70C + 2113540 23 UIKitCore 0x00000001b39198c0 B718818B-0B80-3807-83BF-BB4FD626F70C + 2111680 24 UIKitCore 0x00000001b3921460 B718818B-0B80-3807-83BF-BB4FD626F70C + 2143328 25 UIKitCore 0x00000001b3d563a8 B718818B-0B80-3807-83BF-BB4FD626F70C + 6554536 26 UIKitCore 0x00000001b3e54458 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 244 27 UIKitCore 0x00000001b39211f8 B718818B-0B80-3807-83BF-BB4FD626F70C + 2142712 28 UIKitCore 0x00000001b3763390 B718818B-0B80-3807-83BF-BB4FD626F70C + 316304 29 UIKitCore 0x00000001b3761e30 B718818B-0B80-3807-83BF-BB4FD626F70C + 310832 30 UIKitCore 0x00000001b3762fdc B718818B-0B80-3807-83BF-BB4FD626F70C + 315356 31 UIKitCore 0x00000001b4239a48 B718818B-0B80-3807-83BF-BB4FD626F70C + 11680328 32 UIKitCore 0x00000001b3d7cc1c B718818B-0B80-3807-83BF-BB4FD626F70C + 6712348 33 FrontBoardServices 0x00000001c02abca4 BC7B821F-13EE-3747-8535-E8EABB919812 + 36004 34 FrontBoardServices 0x00000001c02d36d0 BC7B821F-13EE-3747-8535-E8EABB919812 + 198352 35 FrontBoardServices 0x00000001c02b9400 BC7B821F-13EE-3747-8535-E8EABB919812 + 91136 36 FrontBoardServices 0x00000001c02d33e4 BC7B821F-13EE-3747-8535-E8EABB919812 + 197604 37 libdispatch.dylib 0x00000001036915fc _dispatch_client_callout + 16 38 libdispatch.dylib 0x0000000103694ac4 _dispatch_block_invoke_direct + 232 39 FrontBoardServices 0x00000001c02f84a8 BC7B821F-13EE-3747-8535-E8EABB919812 + 349352 40 FrontBoardServices 0x00000001c02f8170 BC7B821F-13EE-3747-8535-E8EABB919812 + 348528 41 FrontBoardServices 0x00000001c02f8644 BC7B821F-13EE-3747-8535-E8EABB919812 + 349764 42 CoreFoundation 0x00000001b1975240 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 631360 43 CoreFoundation 0x00000001b1975140 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 631104 44 CoreFoundation 0x00000001b1974488 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 627848 45 CoreFoundation 0x00000001b196ea40 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 604736 46 CoreFoundation 0x00000001b196e200 CFRunLoopRunSpecific + 572 47 GraphicsServices 0x00000001c7aeb598 GSEventRunModal + 160 48 UIKitCore 0x00000001b4237bcc B718818B-0B80-3807-83BF-BB4FD626F70C + 11672524 49 UIKitCore 0x00000001b423d1a0 UIApplicationMain + 164 50 OLVG Pijn App 0x000000010081b1c0 main + 88 51 libdyld.dylib 0x00000001b164d588 97942B47-8579-3037-ABC2-61C035EF1E70 + 5512." UserInfo={Error Code=2, NSFilePath=/var/mobile/Containers/Data/Application/6D9776FD-9ABE-4C20-A993-1003567246FA/Documents/default.realm, Underlying=Realm file decryption failed Path: /var/mobile/Containers/Data/Application/6D9776FD-9ABE-4C20-A993-1003567246FA/Documents/default.realm Exception backtrace: 0 Realm 0x00000001019cd950 _ZN5realm15InvalidDatabaseC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS19allocatorIcEEEES9 + 60 1 Realm 0x000000010199db7c _ZN5realm9SlabAlloc11attach_fileERKNSt3112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS0_6ConfigE + 2852 2 Realm 0x00000001019cfa10 _ZN5realm2DB7do_openERKNSt3112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbbNS_9DBOptionsE + 3156 3 Realm 0x00000001019d2490 _ZN5realm2DB4openERNS_11ReplicationENS_9DBOptionsE + 244 4 Realm 0x00000001019d6f78 _ZN5realm2DB6createERNS_11ReplicationENS_9DBOptionsE + 392 5 Realm 0x000000010141216c _ZN5realm5_impl16RealmCoordinator7open_dbEv + 992 6 Realm 0x0000000101411374 _ZN5realm5_impl16RealmCoordinator12do_get_realmENS_5Realm6ConfigERNSt3__110shared_ptrIS2_EENS_4util8OptionalINS_9VersionIDEEERNS8_17CheckedUniqueLockE + 68 7 Realm 0x0000000101411190 _ZN5realm5_impl16RealmCoordinator9get_realmENS_5Realm6ConfigENS_4util8OptionalINS_9VersionIDEEE + 668 8 Realm 0x00000001016da470 _ZN5realm5Realm16get_shared_realmENS0_6ConfigE + 176 9 Realm 0x0000000101644704 +[RLMRealm realmWithConfiguration:queue:error:] + 1796 10 RealmSwift 0x00000001032ff6ac $sSo8RLMRealmC13configuration5queueABSo0A13ConfigurationC_So012OS_dispatch_C0CSgtKcfCTO + 156 11 RealmSwift 0x000000010335dd7c $s10RealmSwift0A0V5queueACSo012OS_dispatch_C0CSg_tKcfC + 152 12 OLVG Pijn App 0x000000010081ccd0 $s13OLVG_Pijn_App12RealmManagerC15initializeModelSbyFZ + 380 13 OLVG Pijn App 0x0000000100819b30 $s13OLVG_Pijn_App0C8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtF + 448 14 OLVG Pijn App 0x000000010081a0c4 $s13OLVG_Pijn_App0C8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtFTo + 212 15 UIKitCore 0x00000001b4234120 B718818B-0B80-3807-83BF-BB4FD626F70C + 11657504 16 UIKitCore 0x00000001b42360c0 B718818B-0B80-3807-83BF-BB4FD626F70C + 11665600 17 UIKitCore 0x00000001b423b874 B718818B-0B80-3807-83BF-BB4FD626F70C + 11688052 18 UIKitCore 0x00000001b39196f0 B718818B-0B80-3807-83BF-BB4FD626F70C + 2111216 19 UIKitCore 0x00000001b3e3cb78 _UIScenePerformActionsWithLifecycleActionMask + 100 20 UIKitCore 0x00000001b391a1d8 B718818B-0B80-3807-83BF-BB4FD626F70C + 2114008 21 UIKitCore 0x00000001b3919ce0 B718818B-0B80-3807-83BF-BB4FD626F70C + 2112736 22 UIKitCore 0x00000001b391a004 B718818B-0B80-3807-83BF-BB4FD626F70C + 2113540 23 UIKitCore 0x00000001b39198c0 B718818B-0B80-3807-83BF-BB4FD626F70C + 2111680 24 UIKitCore 0x00000001b3921460 B718818B-0B80-3807-83BF-BB4FD626F70C + 2143328 25 UIKitCore 0x00000001b3d563a8 B718818B-0B80-3807-83BF-BB4FD626F70C + 6554536 26 UIKitCore 0x00000001b3e54458 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 244 27 UIKitCore 0x00000001b39211f8 B718818B-0B80-3807-83BF-BB4FD626F70C + 2142712 28 UIKitCore 0x00000001b3763390 B718818B-0B80-3807-83BF-BB4FD626F70C + 316304 29 UIKitCore 0x00000001b3761e30 B718818B-0B80-3807-83BF-BB4FD626F70C + 310832 30 UIKitCore 0x00000001b3762fdc B718818B-0B80-3807-83BF-BB4FD626F70C + 315356 31 UIKitCore 0x00000001b4239a48 B718818B-0B80-3807-83BF-BB4FD626F70C + 11680328 32 UIKitCore 0x00000001b3d7cc1c B718818B-0B80-3807-83BF-BB4FD626F70C + 6712348 33 FrontBoardServices 0x00000001c02abca4 BC7B821F-13EE-3747-8535-E8EABB919812 + 36004 34 FrontBoardServices 0x00000001c02d36d0 BC7B821F-13EE-3747-8535-E8EABB919812 + 198352 35 FrontBoardServices 0x00000001c02b9400 BC7B821F-13EE-3747-8535-E8EABB919812 + 91136 36 FrontBoardServices 0x00000001c02d33e4 BC7B821F-13EE-3747-8535-E8EABB919812 + 197604 37 libdispatch.dylib 0x00000001036915fc _dispatch_client_callout + 16 38 libdispatch.dylib 0x0000000103694ac4 _dispatch_block_invoke_direct + 232 39 FrontBoardServices 0x00000001c02f84a8 BC7B821F-13EE-3747-8535-E8EABB919812 + 349352 40 FrontBoardServices 0x00000001c02f8170 BC7B821F-13EE-3747-8535-E8EABB919812 + 348528 41 FrontBoardServices 0x00000001c02f8644 BC7B821F-13EE-3747-8535-E8EABB919812 + 349764 42 CoreFoundation 0x00000001b1975240 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 631360 43 CoreFoundation 0x00000001b1975140 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 631104 44 CoreFoundation 0x00000001b1974488 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 627848 45 CoreFoundation 0x00000001b196ea40 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 604736 46 CoreFoundation 0x00000001b196e200 CFRunLoopRunSpecific + 572 47 GraphicsServices 0x00000001c7aeb598 GSEventRunModal + 160 48 UIKitCore 0x00000001b4237bcc B718818B-0B80-3807-83BF-BB4FD626F70C + 11672524 49 UIKitCore 0x00000001b423d1a0 UIApplicationMain + 164 50 OLVG Pijn App 0x000000010081b1c0 main + 88 51 libdyld.dylib 0x00000001b164d588 97942B47-8579-3037-ABC2-61C035EF1E70 + 5512, NSLocalizedDescription=Unable to open a realm at path '/var/mobile/Containers/Data/Application/6D9776FD-9ABE-4C20-A993-1003567246FA/Documents/default.realm': Realm file decryption failed Path:Exception backtrace: 0 Realm 0x00000001019cd950 _ZN5realm15InvalidDatabaseC2ERKNSt3112basic_stringIcNS1_11char_traitsIcEENS19allocatorIcEEEES9 + 60 1 Realm 0x000000010199db7c _ZN5realm9SlabAlloc11attach_fileERKNSt3112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS0_6ConfigE + 2852 2 Realm 0x00000001019cfa10 _ZN5realm2DB7do_openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbbNS_9DBOptionsE + 3156 3 Realm 0x00000001019d2490 _ZN5realm2DB4openERNS_11ReplicationENS_9DBOptionsE + 244 4 Realm 0x00000001019d6f78 _ZN5realm2DB6createERNS_11ReplicationENS_9DBOptionsE + 392 5 Realm 0x000000010141216c _ZN5realm5_impl16RealmCoordinator7open_dbEv + 992 6 Realm 0x0000000101411374 _ZN5realm5_impl16RealmCoordinator12do_get_realmENS_5Realm6ConfigERNSt3110shared_ptrIS2_EENS_4util8OptionalINS_9VersionIDEEERNS8_17CheckedUniqueLockE + 68 7 Realm 0x0000000101411190 _ZN5realm5_impl16RealmCoordinator9get_realmENS_5Realm6ConfigENS_4util8OptionalINS_9VersionIDEEE + 668 8 Realm 0x00000001016da470 _ZN5realm5Realm16get_shared_realmENS0_6ConfigE + 176 9 Realm 0x0000000101644704 +[RLMRealm realmWithConfiguration:queue:error:] + 1796 10 RealmSwift 0x00000001032ff6ac $sSo8RLMRealmC13configuration5queueABSo0A13ConfigurationC_So012OS_dispatch_C0CSgtKcfCTO + 156 11 RealmSwift 0x000000010335dd7c $s10RealmSwift0A0V5queueACSo012OS_dispatch_C0CSg_tKcfC + 152 12 OLVG Pijn App 0x000000010081ccd0 $s13OLVG_Pijn_App12RealmManagerC15initializeModelSbyFZ + 380 13 OLVG Pijn App 0x0000000100819b30 $s13OLVG_Pijn_App0C8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtF + 448 14 OLVG Pijn App 0x000000010081a0c4 $s13OLVG_Pijn_App0C8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0k6LaunchJ3KeyaypGSgtFTo + 212 15 UIKitCore 0x00000001b4234120 B718818B-0B80-3807-83BF-BB4FD626F70C + 11657504 16 UIKitCore 0x00000001b42360c0 B718818B-0B80-3807-83BF-BB4FD626F70C + 11665600 17 UIKitCore 0x00000001b423b874 B718818B-0B80-3807-83BF-BB4FD626F70C + 11688052 18 UIKitCore 0x00000001b39196f0 B718818B-0B80-3807-83BF-BB4FD626F70C + 2111216 19 UIKitCore 0x00000001b3e3cb78 _UIScenePerformActionsWithLifecycleActionMask + 100 20 UIKitCore 0x00000001b391a1d8 B718818B-0B80-3807-83BF-BB4FD626F70C + 2114008 21 UIKitCore 0x00000001b3919ce0 B718818B-0B80-3807-83BF-BB4FD626F70C + 2112736 22 UIKitCore 0x00000001b391a004 B718818B-0B80-3807-83BF-BB4FD626F70C + 2113540 23 UIKitCore 0x00000001b39198c0 B718818B-0B80-3807-83BF-BB4FD626F70C + 2111680 24 UIKitCore 0x00000001b3921460 B718818B-0B80-3807-83BF-BB4FD626F70C + 2143328 25 UIKitCore 0x00000001b3d563a8 B718818B-0B80-3807-83BF-BB4FD626F70C + 6554536 26 UIKitCore 0x00000001b3e54458 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 244 27 UIKitCore 0x00000001b39211f8 B718818B-0B80-3807-83BF-BB4FD626F70C + 2142712 28 UIKitCore 0x00000001b3763390 B718818B-0B80-3807-83BF-BB4FD626F70C + 316304 29 UIKitCore 0x00000001b3761e30 B718818B-0B80-3807-83BF-BB4FD626F70C + 310832 30 UIKitCore 0x00000001b3762fdc B718818B-0B80-3807-83BF-BB4FD626F70C + 315356 31 UIKitCore 0x00000001b4239a48 B718818B-0B80-3807-83BF-BB4FD626F70C + 11680328 32 UIKitCore 0x00000001b3d7cc1c B718818B-0B80-3807-83BF-BB4FD626F70C + 6712348 33 FrontBoardServices 0x00000001c02abca4 BC7B821F-13EE-3747-8535-E8EABB919812 + 36004 34 FrontBoardServices 0x00000001c02d36d0 BC7B821F-13EE-3747-8535-E8EABB919812 + 198352 35 FrontBoardServices 0x00000001c02b9400 BC7B821F-13EE-3747-8535-E8EABB919812 + 91136 36 FrontBoardServices 0x00000001c02d33e4 BC7B821F-13EE-3747-8535-E8EABB919812 + 197604 37 libdispatch.dylib 0x00000001036915fc _dispatch_client_callout + 16 38 libdispatch.dylib 0x0000000103694ac4 _dispatch_block_invoke_direct + 232 39 FrontBoardServices 0x00000001c02f84a8 BC7B821F-13EE-3747-8535-E8EABB919812 + 349352 40 FrontBoardServices 0x00000001c02f8170 BC7B821F-13EE-3747-8535-E8EABB919812 + 348528 41 FrontBoardServices 0x00000001c02f8644 BC7B821F-13EE-3747-8535-E8EABB919812 + 349764 42 CoreFoundation 0x00000001b1975240 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 631360 43 CoreFoundation 0x00000001b1975140 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 631104 44 CoreFoundation 0x00000001b1974488 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 627848 45 CoreFoundation 0x00000001b196ea40 58021D2F-E0D8-3FD1-805D-ECF92B4E0CB0 + 604736 46 CoreFoundation 0x00000001b196e200 CFRunLoopRunSpecific + 572 47 GraphicsServices 0x00000001c7aeb598 GSEventRunModal + 160 48 UIKitCore 0x00000001b4237bcc B718818B-0B80-3807-83BF-BB4FD626F70C + 11672524 49 UIKitCore 0x00000001b423d1a0 UIApplicationMain + 164 50 OLVG Pijn App 0x000000010081b1c0 main + 88 51 libdyld.dylib 0x00000001b164d588 97942B47-8579-3037-ABC2-61C035EF1E70 + 5512.} Fatal error: Unexpectedly found nil while unwrapping an Optional value: file OLVG_Pijn_App/RLMUser.swift, line 82 2020-11-19 16:12:59.854125+0100 OLVG Pijn App[7936:2716324] Fatal error: Unexpectedly found nil while unwrapping an Optional value: file OLVG_Pijn_App/RLMUser.swift, line 82

fvvliet commented 3 years ago

Is this stack trace enough to debug the issue ?

leemaguire commented 3 years ago

@fvvliet Could you share how you are using encryption? Specifically encryptionKey(). I cannot reproduce this on our end using this example for creating an encryption key https://github.com/realm/realm-cocoa/blob/master/examples/ios/swift/Encryption/ViewController.swift

fvvliet commented 3 years ago

private extension RealmManager {

class func configuration() throws -> Realm.Configuration {

    var config = Realm.Configuration()

    config.encryptionKey = encryptionKey().data(using: .utf8)!
    config.schemaVersion = 1

// log.info("Realm configuration: (config)")

    return config
}

/**
 We have to enter this encryption key in the Realm Browser cause our database is encrypted
 */
class func encryptionKey() -> String {
    let key = UIDevice.current.identifierForVendor!.uuidString + "-" + UIDevice.current.identifierForVendor!.uuidString
    let index = key.index(key.startIndex, offsetBy: 64)
    return key.substring(to: index)
}

}

leemaguire commented 3 years ago

@fvvliet Using UIDevice.current.identifierForVendor is a very unstable way to generate an encryption key, a lot of problems can come from it. See https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor I would recommend that you use the link I shared in my previous post that shows how to read / write an encryption key to the keychain.

fvvliet commented 3 years ago

@leemaguire Ah of course, you're right ;-)

Thanks for your advice 👍

ejm01 commented 3 years ago

Closing because it looks like a solution was provided. Please comment if this needs to be re-opened.