“ RLMException”,原因:“此版本的Realm不支持打开格式版本11的Realm文件”

时间:2020-07-09 11:28:52

标签: swift realm

我正在尝试登录领域,但是它一直抛出RLMException错误。

这是我的pod文件

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'App' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for App
pod 'RealmSwift'

target 'AppUITests' do
  # Pods for testing
end

end

这是登录功能

func login(){
    
    let usernameCredentials = SyncCredentials.usernamePassword(username: "user", password: "password")
    // Create the configuration
    let syncServerURL = URL(string: "realms://jaffjf.faf.cloud.realm.io/default")!
    SyncUser.logIn(with: usernameCredentials, server: syncServerURL) { user, error in
            if let user = user {
                print("logged in",user)
                 let config = user.configuration(realmURL: syncServerURL);

            // Open the remote Realm
            let realm = try! Realm(configuration: config)
          
            
              Realm.asyncOpen(configuration: config) { realm, error in
                        if let realm = realm {
                          
                            let results = realm.objects(Temp.self)
                            print("This is the results......", results)
             
           
                        } else if let error = error {
                        
                            print("No realm found....")
                        }
                    }
            
        } else if let error = error {
            
        }
    }
    

由于未捕获的异常“ RLMException”而终止应用程序,原因:“此版本的Realm不支持打开格式版本11的Realm文件” ***首先抛出调用堆栈:

是什么原因导致该错误,我该如何解决?

2 个答案:

答案 0 :(得分:2)

此错误表明您需要使用Realm Cocoa 5.4.x,目前最新版本为5.4.5。

答案 1 :(得分:0)

只需打开文件路径的查找器并删除领域文件。 然后再次构建您的项目。

我以这种方式解决了同样的问题。

相关问题