2

I want to use pre-filled encrypted realm db in my iOS Application. I tried to put it in Bundle and then to read it. It works well if I will use NOT encrypted realm DB, but if I use encrypted app can't open realm.

I tried to create pre-filled encrypted realm db using my own Mac app and using node.js sdk. In both cases iOS app can't open and decrypt realm. Without encryption everything works perfect.

If then I will try to open this realm file using Realm browser everything will open! I am sure that realm is encrypted, because Realm Browser asks me for the key. I entered it and it works.

What is interesting is that encrypted realm is easily can be read by simulator but not the real device.

Goals

To make Swift Realm working with encrypted realm files created using not iOS sdk.

Actual Results

Error Domain=io.realm Code=2 "Unable to open a realm at path '/var/containers/Bundle/Application/73CBF3CD-1E1E-4C7B-85E3-607D20217DCC/app-app.app/config.realm': Realm file decryption failed." UserInfo={Error Code=2, NSFilePath=/var/containers/Bundle/Application/73CBF3CD-1E1E-4C7B-85E3-607D20217DCC/app-app.app/config.realm, Underlying=Realm file decryption failed, NSLocalizedDescription=Unable to open a realm at path '/var/containers/Bundle/Application/73CBF3CD-1E1E-4C7B-85E3-607D20217DCC/app-app.app/config.realm': Realm file decryption failed.}

Code Sample

let encryptionConfig = Realm.Configuration(
            fileURL: pathToRealmInBundle,
            encryptionKey: encryptionKey,
            readOnly: true,
            objectTypes: [
                ...
            ]
        )
        guard let realm = try? Realm(configuration: encryptionConfig) else {
            print("Fail")
            return nil
        }

Version of Realm and Tooling

Realm framework version: 3.0.2

Xcode version: Version 9.1 (9B55)

iOS/OSX version: iPhone 6 iOS 11.1.2

Dependency manager + version: Pod 1.3.1

0

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.