How I fixed Realm crash in KMP Desktop on older macOS versions

I am Denis, Middle Android developer at Black Bricks. In our KMP project, we use Realm to work with the database. Everything went smoothly while we were developing the project on machines running current versions of macOS. But after the first large external testing, it turned out that many users were running macOS 10.13-11.6. On these versions, our project crashed with an error: librealmc.dylib was prebuild for macOS 12.7.

At first there was a snag finding a machine on the old macOS. You can't just install a virtual machine on M-chips, since 10.13-11.6 does not support ARM. But I still managed to find a MacBook Air on 11.6. I tried to compile a build in Android Studio – the same errors that I indicated above. After googling, I came across a card in JIRA.

Untitled

I dug deep into the library realm-kotlinit depends on realm-core. Which, in turn, contains an interesting block of code:

let platforms: [SupportedPlatform] = [
    .macOS(.v12_7),
    .iOS(.v12),
    .tvOS(.v12),
    .watchOS(.v4)
]

New versions of Realm for KMP use realm-core, where the supported macOS version is from 12.7.

1.16.0

Kotlin 1.9.0+
Ktor 2.1.2+.
Coroutines 1.7.0+.
Gradle 6.8.3 – 8.5

1.8.0

Kotlin 1.7.20+
Ktor 2.1.2+.
Coroutines 1.6.4+.
Gradle 6.7.1 – 7.6.1

1.7.0

Kotlin 1.7.20-1.8.10
Ktor 2.1.2+.
Coroutines 1.6.4+.
Gradle 6.7.1 – 7.6.1

I had to look through the library commits to find the right version of kotlin-core that would use realm-core with supported macOS 10.13+. 1.7.0 worked for this.

Because of this, Kotlin and some dependencies had to be downgraded to be compatible with Realm 1.7.0, which is expensive for a large project at release stage.

For fun, I tried to launch an open source KMP project with Room. The project launched on older macOS without any problems and even with Kotlin 2.0. So if the goal is to support older versions of macOS and you are wondering whether to choose Realm or Room, I recommend Room.

Thank you for reading!

Denis Popkov

Middle Android Developer at Black Bricks

If you found any inaccuracies/errors in the article or just want to add your opinion, please leave a comment! Or you can write to me in Telegram — t.me/MolodoyDenis.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *