etayluz etayluz - 1 month ago 14x
iOS Question

Realm: Module 'Realm has no member named 'Configuration'

I am trying to enable encryption with realm using the latest official documentation:

This is the code from the documentation:

import Foundation
import Realm

class TestRealm:NSObject {

func test() {
// Generate a random encryption key
let key = NSMutableData(length: 64)!
SecRandomCopyBytes(kSecRandomDefault, key.length,

// Open the encrypted Realm file
let config = Realm.Configuration(encryptionKey: key)
do {
let realm = try Realm(configuration: config)
// Use the Realm as normal
} catch let error as NSError {
// If the encryption key is wrong, `error` will say that it's an invalid database
fatalError("Error opening realm: \(error)")

I am receiving a compilation error on this line:

let config = Realm.Configuration(encryptionKey: key)

Module 'Realm has no member named 'Configuration'

I am using Realm 1.0.2


You need import RealmSwift, not import Realm. import Realm gives you the Objective-C API.