let config = Realm.Configuration(
// Set the new schema version. This must be greater than the previously used
// version (if you\'ve never set a
I also had this issue happening where my app would crash despite the fact that I added the default migration code in didFinishLaunchingWithOptions
As already stated here, the problem was that I was initializing an instance of Realm in my first view controller as a class level property.
BUT I couldn't just remove this instance and put it in the viewDidLoad, as I needed to use it in several functions.
The solution was actually to add the 'lazy' keyword, so the migration can be done before the initialization, as I found over here: https://www.selmanalpdundar.com/solution-of-realm-migration-error-code-10.html
import UIKit
import RealmSwift
class ViewController: UIViewController {
lazy var realm = try! Realm() //added lazy and changed let to var
}