Crash in TestFligh when pre-populated realm schema is updated

Our app runs perfectly well on both the simulator and the device. But it crashes in TestFlight when we try to view any screen that displays data from the database.

Here’s our code:
`init() {
guard fileManager.urls(for: .documentDirectory, in: .userDomainMask).first != nil else { return }
let defaultPath = Realm.Configuration.defaultConfiguration.fileURL?.path
let path = Bundle.main.path(forResource:"(REALM_DATABASE)", ofType: “realm”)

    let alreadyExists = fileManager.fileExists(atPath:defaultPath ?? "")
    
    let configuration = Realm.Configuration(schemaVersion: BayanRealmDatabase.schemaVersion,migrationBlock: {
        [self] migration, oldSchemaVersion in
        if oldSchemaVersion < BayanRealmDatabase.schemaVersion {
            if alreadyExists == true, let bundledPath = path {
                print("use pre-populated database")
                do {
                    try fileManager.removeItem(atPath:defaultPath ?? "")
                    try fileManager.copyItem(atPath:bundledPath, toPath: defaultPath ?? "")
                    
                } catch {
                    print("remove")
                    print(error)
                }
            } else {
                do {
                    try fileManager.copyItem(atPath:path ?? "", toPath: defaultPath ?? "")
                } catch {
                    print("remove")
                    print(error)
                }
            }
        }
    }, deleteRealmIfMigrationNeeded: false)
    Realm.Configuration.defaultConfiguration = configuration
    do {
        database = try Realm()
    } catch {
        print(error.localizedDescription)
    }
}`

Can you help?