Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

ios - Cannot open default.realm file using Realm Studio or Realm Browser

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...