checkout stetho and https://github.com/uPhyca/stetho-realm Video tutorial here: https://www.youtube.com/watch?v=9pFJz5VexRw
Either:
debugPrint("Path to realm file: " + realm.configuration.fileURL!.absoluteString)
Step 1: Have a constant called dev somewhere. Let's say Constant file
public class Constants {
public static var dev: Bool = true
}
Step 2: Create another class called RealmFunctions.swift
import RealmSwift
func realmAndPath() -> Realm {
if Constants.dev {
// location of my desktop
let testRealmURL = NSURL(fileURLWithPath: "/Users/#####/Desktop/TestRealm.realm")
return try! Realm(fileURL: testRealmURL)
} else {
return try! Realm()
}
}
Step 3: finally in your view controller:
let realm = realmAndPath()
thanks to Stewart Lynch for the original answer