Skip to content

Realm DB compatibility issue between Swift SDK and React Native app #8703

@sheetalj27

Description

@sheetalj27

How frequently does the bug occur?

Always

Description

Description:
I've developed a React Native app that uses a Swift SDK, both of which rely on Realm DB. The following versions are in use:

iOS (SPM): https://github.com/realm/realm-swift.git, version 10.12.0
React Native: "realm": "^20.0.0"
Problem:
Screenshot 2024-10-30 at 2 00 06 PM

The app crashes when attempting to write an object in Realm.

One of our clients also uses this SDK in their React Native app, and they are encountering the following error:

Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=15 "History schema version not consistent" UserInfo={Error Name=IncompatibleSession, NSLocalizedDescription=History schema version not consistent, Error Code=15}

This issue only occurs in the React Native environment. We don't have exact version details for the client's environment.

Stacktrace & log output

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

Can you reproduce the bug?

Always

Reproduction Steps

Set up the React Native app:

Initialize a new React Native project.
npm install [email protected] --save

Integrate the Swift SDK:
Use Swift Package Manager to include the SDK:
.package(url: "https://github.com/realm/realm-swift.git", .upToNextMajor(from: "10.12.0")),

The SDK uses Realm Swift version 10.12.0.

Invoke the Swift SDK from React Native:
Use React Native's NativeModules to call methods from the Swift SDK.
Within the Swift SDK, attempt to write an object to Realm:
let realm = try! Realm()
try! realm.write {
realm.add(myObject)
}
Run the React Native app and trigger the Swift SDK method.

Expected Behavior:
The object should be written to the Realm database without any crashes or errors.
Actual Behavior:
The app crashes with the error mentioned above when the Swift SDK attempts to write to Realm.

Version

this is version independent

What Atlas Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

17.2

Build environment

Xcode version: 15.1
swift-tools-version: 5.9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions