0

I've checked other threads regarding this and haven't managed to have any luck with implementing the answers so have resorted to starting another post. Sorry!

I'm currently completing a Swift course and have run into some issues while using Realm for the first time. Installing Realm into my app with Cocoapods seemed to go to plan but when attempting to open the Realm database (default.realm) I came across the following errors:

Error when opening with Realm Browser, asking for an encryption key (not sure where to get this from, but judging by other posts it seems to be something to do with opening a local version of a synced Realm file) : screenshot1

Error message when opening with Realm Studio: screenshot2

I have tried downloading previous versions of Realm Studio but to no avail. I do not want to update to Xcode 12 just yet as the course I am completing relates to Xcode 11 and I'm halfway through a project. It also seems as though the problem is Realm related.

Here are some details of the cocoapods versions etc.:

PODS:

  • Realm (5.4.2):
    • Realm/Headers (= 5.4.2)
  • Realm/Headers (5.4.2)
  • RealmSwift (5.4.2):
    • Realm (= 5.4.2)

DEPENDENCIES:

  • RealmSwift

SPEC REPOS: trunk: - Realm - RealmSwift

SPEC CHECKSUMS: Realm: ced868eb0254f8d33a21c06981355e5aa33bc005
RealmSwift: aedc4363150f3c61f91ae0537ed116d2d080a4dd

PODFILE CHECKSUM: 4b5257d74bf1a8c39ac0b1f3a9a6e9fd23a03b98

COCOAPODS: 1.9.3 ~
"Podfile.lock" 22L, 408C

Here are some further details of what I'm running

ProductName: Mac OS X ProductVersion: 10.15.5 BuildVersion: 19F101

/Applications/Xcode.app/Contents/Developer Xcode 11.6 Build version 11E708

/usr/local/bin/pod 1.9.3 Realm (5.4.2) RealmSwift (5.4.2)

/bin/bash GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)

/usr/bin/git git version 2.24.3 (Apple Git-128)

Here is the code from AppDelegate, not sure it'll help but the print statement is how I found the default.realm file:

import UIKit
import CoreData
import RealmSwift

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
    print(Realm.Configuration.defaultConfiguration.fileURL!)
    
    let data = Data()
    data.name = "Josh"
    data.age = 13
    
    do {
        let realm = try Realm()
        try realm.write {
            realm.add(data)
        }
    } catch {
        print("Error initialising new Realm: \(error)")
    }

Apologies but I've only just started learning and don't really have a clue where to go from here in opening the default.realm file, so any help would be massively appreciated!

treazon
  • 56
  • 6
  • Welcome to SO. It's a good idea to do some research before posting questions. It can save a bunch of time. See this [question and answer](https://stackoverflow.com/questions/63913088/realm-studio-cant-open-new-realm-file-generated-from-nodejs-realm-v6-1-1/63962140#63962140) as well as [this one](https://stackoverflow.com/questions/63955783/opening-realm-files-of-format-version-11-is-not-supported-by-this-version-of-rea#comment113105108_63955783). Also, Realm Browser is a depreciated product and should not be used. Realm Studio is the appropriate replacement for both Realm and MongoDB Realm. – Jay Sep 21 '20 at 17:28
  • Also, just as a side note, try to avoid naming classes with the same names as existing classes; `Data` is a Swift class that had its start with `NSData`. Try to be more descriptive; `class UserClass: Object {` to hold user data or `class CarClass: Object {` to hold info about a specific car – Jay Sep 21 '20 at 17:34
  • Thanks for the reply Jay. I actually found those exact posts but to a beginner it's all a bit difficult to understand. I tried installing release 3.10 (as per the first link) prior to posting the question but had the same issue. In addition, I wasn't actually using mongoDB so the second answer did not apply. Perhaps the module I'm studying is outdated, so I'm going to use a different tutorial to learn mongoDB Realm instead. Thanks again. Re side note, the `Data` class, albeit not ideal, was actually part of the tutorial and was being used as an example of how Realm works, thanks though – treazon Sep 21 '20 at 20:20
  • The second article is highly relevant as Realm will be depreciated at some point in favor of MongoDB Realm. You should really go through one of the getting started guides. I would really suggest classic Realm SDK 5.x, [Realm Getting Started](https://realm.io/docs/swift/latest/). If you want to explore the Beta MongoDB Realm go to that [Getting Started](https://docs.mongodb.com/realm/) – Jay Sep 21 '20 at 21:59
  • I've gone through the procedure in the first link 'Realm Getting Started' around 5 times now, using a brand new project, the latest versions of Cocoapods, Realm and Realm Studio but still get the 'Opening Realm files of format version 11 is not supported by this version of Realm' message when trying to open the default.realm file (located using this code: `print(Realm.Configuration.defaultConfiguration.fileURL)`. I think I might just sack off Realm and go for the MongoDB Realm Beta if that's going to be the future anyway. Thanks again – treazon Sep 22 '20 at 09:50
  • Again, you're using incompatible versions. You should have Realm 5.x SDK, Realm Studio 3.11 and your podfile should include `pod 'RealmSwift'` and no other pods. You will need to delete the Realm previously created as it's already been updated. – Jay Sep 22 '20 at 17:07
  • It seems as though they've just added Realm Studio 5.0 (earlier today version 4.0 was the latest) and after downloading that it's working fine. Thanks for all the help! – treazon Sep 22 '20 at 19:22

2 Answers2

0

Following the release of a new version of Realm Studio, and after updating everything to the latest versions, specifically Cocoapods 1.10 beta, Realm 5.4.3 and Realm Studio 5.0, Realm Studio is now able to open the default.realm file.

treazon
  • 56
  • 6
0

I was not being able to open default.realm file too (I was using Realm Studio Version 3.10.1). And also not being able to connect to the realm cloud. I checked the realm studio website and I saw that the application now is called "MongoDB Realm Studio" and not "Reaml Studio" anymore. I Installed the new application and now I can open it.

Jujuba
  • 341
  • 3
  • 8