Reputation: 271
I can't find a way to read my Realm file. I assumed Realm is backwards compatible. The Realm objects/attributes/classes have remained exactly the same. I tried changing the schema and also tried custom migration, which is impossible because I get "Opening Realm files of format version 5 is not supported by this version of Realm" as soon as I tried to read from Realm. I have tried many tricks i've read in other posts such as forcing readOnly to false:
let version = Realm.Configuration.defaultConfiguration.schemaVersion
print("schema version \(version)")
var configuration = Realm.Configuration(readOnly: false, schemaVersion: 1)
try! Realm(configuration: configuration) //FAILS Opening Realm files of format version 5 is not supported by this version of Realm
configuration = Realm.Configuration(readOnly: true)
let realm = try! Realm(configuration: configuration)
I can't update the app on the App Store because people with a previous version will have their app crash, and I don't want to delete their Realm file and get bad reviews because they lost all their data. Is there any option without downgrading to an earlier version of realm?
I'm using XCode 12.4 and swift 5. The schema of the Realm file is unchanged. The issue was supposed to be solved in Realm v5.4.1 on 9/20/2021. I have the latest version of Realm installed but the issue is not resolved. https://swift.libhunt.com/realm-cocoa-changelog?page=4
I've have also tried resetting the integration state:
pod cache clean Realm
pod cache clean RealmSwift
pod deintegrate || rm -rf Pods
pod install --verbose
rm -rf ~/Library/Developer/Xcode/DerivedData
My version info:
tee /dev/tty | pbcopy
ProductName: macOS
ProductVersion: 11.1
BuildVersion: 20C69
/Applications/Xcode.app/Contents/Developer
Xcode 12.4
Build version 12D4e
/Users/Paul/.rvm/rubies/ruby-2.4.1/bin/pod
1.10.1
Realm (10.5.1)
RealmSwift (10.5.1)
/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
/usr/bin/git
git version 2.24.3 (Apple Git-128)
My Pod File:
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
target 'Vending Receipt' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Vending Receipt
pod 'Realm'
pod 'RealmSwift' #, :git => 'https://github.com/realm/realm-cocoa.git', :branch => 'master'
pod 'BTNavigationDropdownMenu'
pod 'SCLAlertView', :git => 'https://github.com/vikmeup/SCLAlertView-Swift.git'
target 'Vending ReceiptTests' do
inherit! :search_paths
use_frameworks!
# Pods for testing
pod 'Realm'
pod 'RealmSwift' #, :git => 'https://github.com/realm/realm-cocoa.git', :branch => 'master'
pod 'BTNavigationDropdownMenu'
pod 'SCLAlertView', :git => 'https://github.com/vikmeup/SCLAlertView-Swift.git'
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
config.build_settings['EXCLUDED_ARCHS[sdk=watchsimulator*]'] = 'arm64'
config.build_settings['EXCLUDED_ARCHS[sdk=appletvsimulator*]'] = 'arm64'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
end
The crash log is below:
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=6 "Opening Realm files of format version 5 is not supported by this version of Realm" UserInfo={Error Code=6, NSFilePath=/var/mobile/Containers/Data/Application/04864A2A-4605-49B2-893F-15F76F60DD9B/Documents/default.realm, Underlying=Database has an unsupported version (5) and cannot be upgraded Exception backtrace:
0 Realm 0x000000010104e4ac _ZN5realm2DB7do_openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbbNS_9DBOptionsE + 5356 1 Realm 0x0000000101050694 _ZN5realm2DB4openERNS_11ReplicationENS_9DBOptionsE + 244
2 Realm 0x000000010105517c _ZN5realm2DB6createERNS_11ReplicationENS_9DBOptionsE + 392
3 Realm 0x0000000100b5cf40 _ZN5realm5_impl16RealmCoordinator7open_dbEv + 992
4 Realm 0x0000000100b5c148 _ZN5realm5_impl16RealmCoordinator12do_get_realmENS_5Realm6ConfigERNSt3__110shared_ptrIS2_EENS_4util8OptionalINS_9VersionIDEEERNS8_17CheckedUniqueLockE + 68
5 Realm 0x0000000100b5bf64 _ZN5realm5_impl16RealmCoordinator9get_realmENS_5Realm6ConfigENS_4util8OptionalINS_9VersionIDEEE + 668
6 Realm 0x0000000100e4f204 _ZN5realm5Realm16get_shared_realmENS0_6ConfigE + 176
7 Realm 0x0000000100db93d4 +[RLMRealm realmWithConfiguration:queue:error:] + 1796
8 RealmSwift 0x0000000102a6f478 $sSo8RLMRealmC13configuration5queueABSo0A13ConfigurationC_So012OS_dispatch_C0CSgtKcfCTO + 156
9 RealmSwift 0x0000000102ac8734 $s10RealmSwift0A0V13configuration5queueA2C13ConfigurationV_So012OS_dispatch_D0CSgtKcfC + 216
10 Vending Receipt 0x000000010050d0cc $s15Vending_Receipt0B7StorageC11getReceipts_5sort15sort29ascending10RealmSwift7ResultsVyAA0B0CGSS_S2SSbtF + 1572
11 Vending Receipt 0x00000001004e4868 $s15Vending_Receipt14SearchReceiptsC11UpdateTableyyF + 1980
12 Vending Receipt 0x00000001004e11d0 $s15Vending_Receipt14SearchReceiptsC11viewDidLoadyyF + 5768
13 Vending Receipt 0x00000001004e1250 $s15Vending_Receipt14SearchReceiptsC11viewDidLoadyyFTo + 32
14 UIKitCore 0x00000001a72f2e50 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 4623952
15 UIKitCore 0x00000001a72f7408 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 4641800
16 UIKitCore 0x00000001a72f77e8 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 4642792
17 UIKitCore 0x00000001a722b738 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 3807032
18 UIKitCore 0x00000001a723fbb0 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 3890096
19 UIKitCore 0x00000001a7240fe0 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 3895264
20 UIKitCore 0x00000001a7223e78 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 3776120
21 UIKitCore 0x00000001a7ec2398 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 17007512
22 QuartzCore 0x00000001a83c7df4 461501DD-204F-3516-9F5D-BDD0BA19FDA1 + 1400308
23 QuartzCore 0x00000001a83ce398 461501DD-204F-3516-9F5D-BDD0BA19FDA1 + 1426328
24 QuartzCore 0x00000001a83d96e8 461501DD-204F-3516-9F5D-BDD0BA19FDA1 + 1472232
25 QuartzCore 0x00000001a8324d7c 461501DD-204F-3516-9F5D-BDD0BA19FDA1 + 732540
26 QuartzCore 0x00000001a834ef40 461501DD-204F-3516-9F5D-BDD0BA19FDA1 + 905024
27 UIKitCore 0x00000001a79b6d8c CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 11718028
28 UIKitCore 0x00000001a7a5dac4 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 12401348
29 UIKitCore 0x00000001a7a54afc CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 12364540
30 CoreFoundation 0x00000001a50cdbf0 F3021642-E3C0-33F8-9911-DD303A6056D0 + 633840
31 CoreFoundation 0x00000001a50cdaf0 F3021642-E3C0-33F8-9911-DD303A6056D0 + 633584
32 CoreFoundation 0x00000001a50cce38 F3021642-E3C0-33F8-9911-DD303A6056D0 + 630328
33 CoreFoundation 0x00000001a50c73e0 F3021642-E3C0-33F8-9911-DD303A6056D0 + 607200
34 CoreFoundation 0x00000001a50c6ba0 CFRunLoopRunSpecific + 572
35 GraphicsServices 0x00000001bbe2f598 GSEventRunModal + 160
36 UIKitCore 0x00000001a79b82f4 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 11723508
37 UIKitCore 0x00000001a79bd874 UIApplicationMain + 164
38 Vending Receipt 0x00000001004d3444 main + 88
39 libdyld.dylib 0x00000001a4da5568 0B475C78-3C12-3121-B7F8-2B95B83DAF44 + 5480, NSLocalizedDescription=Opening Realm files of format version 5 is not supported by this version of Realm}: file Vending_Receipt/ReceiptModel.swift, line 52 2021-02-01 15:16:21.102889-0600 Vending Receipt[558:58472] Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=6 "Opening Realm files of format version 5 is not supported by this version of Realm" UserInfo={Error Code=6, NSFilePath=/var/mobile/Containers/Data/Application/04864A2A-4605-49B2-893F-15F76F60DD9B/Documents/default.realm, Underlying=Database has an unsupported version (5) and cannot be upgraded
Upvotes: 1
Views: 1391
Reputation: 17971
The core confusion is in the wording Realm files of format version 5
.
The file format version is a different number from the Realm SDK Version.
Unfortunately, I don't think this correspondence of versions is clearly documented anywhere.
Searching the changelog for mention of format is the only way I know.
An important version probably fixed your upgrade woes 10.7.1 which Restores support for upgrading files from file format 5 (Realm Cocoa 1.x)
From my sheet which has much more detail:
Upvotes: 2
Reputation: 271
Question was answered on Github:
v5.0.0 dropped support for opening Realm files written by versions before v3.0.0.
We support migrating from 6+ and the 5->6 migration just consisted of recreating the string indexes.
Upvotes: 1