此版本的Realm不支持打开格式为版本5的Realm文件



我找不到读取Realm文件的方法。我认为Realm是向后兼容的。Realm对象/属性/类保持完全相同。我尝试过更改模式,也尝试过自定义迁移,这是不可能的,因为我得到了"此版本的Realm不支持打开格式版本5的Realm文件;我刚试着读《境界》。我已经尝试了很多我在其他帖子中读到的技巧,比如强迫readOnly为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)

我无法在应用商店上更新应用程序,因为使用以前版本的人的应用程序会崩溃,我不想删除他们的Realm文件并获得差评,因为他们丢失了所有数据。有没有任何选项可以不降级到早期版本的领域?

我使用的是XCode 12.4和swift 5。Realm文件的架构保持不变。该问题本应在2021年9月20日的Realm v.4.1中解决。我安装了最新版本的Realm,但问题没有解决。https://swift.libhunt.com/realm-cocoa-changelog?page=4
我还尝试过重置集成状态:

pod cache clean Realm
pod cache clean RealmSwift
pod deintegrate || rm -rf Pods
pod install --verbose
rm -rf ~/Library/Developer/Xcode/DerivedData

我的版本信息:

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)

我的播客文件:

# 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

崩溃日志如下:

致命错误:"try!"表达式意外引发错误:错误域=io.realm代码=6"此版本的Realm不支持打开格式版本5的Realm文件;UserInfo={错误代码=6,NSFilePath=/var/mobile/Contaness/Data/Application/04864A2A-4605-49B2-893F-15F76F60DD9B/Documents/default.realm,Underlying=数据库具有不支持的版本(5),无法升级异常回溯:

0领域0x000000010104e4ac _ZN5realm2DB7do_openERKNSt3__112basic_stringIcNS1_11 char_traitsIcEENS1_9分配器IcEEEEbbNS_9DB选项E+55361领域0x0000000101050694 _ZN5realm2DB4打开ERNS_11复制ENS_9DBOptionsE+244

2领域0x000000010105517c_ZN5realm2DB6创建ERNS_11复制ENS_9DB选项E+392

3领域0x0000000100b5cf40 _ZN5realm5_impl16RealmCoordinator7open_dbEv+992

4领域0x0000000100b5c148 _ZN5realm5_impl16RealmCoordinator12do_get_realmENS_5Realm6ConfigERNS3__110shared_ptrIS2_EENS_4util8OptionalINS_9VersionIDEEENS8_17CheckedUniqueLockE+68

5领域0x0000000100b5bf64_ZN5realm5_impl16RealmCoordinator9get_realmENS_5Realm6ConfigENS_4util8OptionalINS_9VersionIDEEE+668

6领域0x0000000100e4f204 _ZN5realm5Realm16get_shared_almENS0_6ConfigE+176

7 Realm 0x0000000100db93d4+[RLMRealmWithConfiguration:队列:错误:]+1796

8 RealmSwift 0x0000000102a6f478$SSo8RLMRealmC13配置5queueABSo0A13配置C_So012OS_dispatch_C0CSgtKcfCTO+156

9 RealmSwift 0x0000000102ac8734$s10RealmSwift0A0V13配置5queueA2C13配置V_So012OS_dispatch_D0CSgtKcfC+216

10自动售货收据0x000000010050d0cc$115自动售货收据0B7存储C11getReceipts_5sort15sort29上升10RealmSwift7结果VyAA0B0CGSS_S2SSbtF+1572

11售货收据0x00000001004e4868$15售货收据14SearchReceipts11更新表格yyF+1980

12自动售货收据0x00000001004e11d0$115自动售货收据14搜索收据11viewDidLoadyyyF+5768

13自动售货收据0x00000001004e1250$15VendingReceipt14SearchReceipts11viewDidLoadyyFTo+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+9905024

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核心基础0x00000001a50dbf0 F3021642-E3C0-33F8-9911-DD303A6056D0+633840

31核心基础0x00000001a50daf0 F3021642-E3C0-33F8-9911-DD303A6056D0+633584

32核心基础0x00000001a5cce38 F3021642-E3C0-33F8-9911-DD303A6056D0+630328

33核心基础0x00000001a50c73e0 F3021642-E3C0-33F8-9911-DD303A6056D0+607200

34 CoreFoundation 0x00000001a506ba0 CFRunLoopRunSpecific+572

35 GraphicsServices 0x00000001be2f598 GSEventRunModal+160

36 UIKitCore 0x00000001a79b82f4 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A+11723508

37 UIKitCore 0x00000001a79bd874 UIApplicationMain+164

38自动售货收据0x00000001004d3444主+88

39 libdyld.dylib 0x00000001a4da5568 0B475C78-3C12-3121-B7F8-2B95B83DAF44+5480,NSLocalizedDescription=此版本的Realm不支持打开格式为版本5的Realm文件}:file Vending_ReiptModel.swift,第52行2021-02-01 15:16:21.102889-0600自动售货收据[558:58472]致命错误:"尝试!"表达式意外引发错误:错误域=io.realm代码=6"此版本的Realm不支持打开格式版本5的Realm文件;UserInfo={错误代码=6,NSFilePath=/var/mobile/Contaness/Data/Application/04864A2A-4605-49B2-893F-15F76F60DD9B/Documents/default.realm,Underlying=数据库的版本不受支持(5),无法升级

问题已在Github:上得到回答

v5.0.0放弃了对打开v3.0.0之前版本编写的Realm文件的支持。

我们支持从6+和5->6迁移只包括重新创建字符串索引。

核心混淆在于措辞Realm files of format version 5

文件格式版本

Realm SDK版本不幸的是,我不认为这些版本的对应关系在任何地方都有明确的记录。

在变更日志中搜索格式是我唯一知道的方法。

一个重要的版本可能修复了您的升级问题10.7.1,该版本恢复了对从文件格式5(Realm Cocoa 1.x)升级文件的支持

根据我的表格,其中有更多的细节:

  • SDK 10.8.0生成格式为v22的领域
  • SDK 10.0.0生成格式为v11的领域
  • SDK 5.4.0也生成v11格式的Realms(MongoDB之前的最后一个独立版本?)
  • SDK 2.4…2.10格式6
  • SDK 1.x格式5

最新更新