Today, I've released version 1.0.0 of Multiplatform Settings. That means I'm committed to maintaining the current API surface of everything not marked as experimental until there's a 2.0 release (which I don't currently have plans for). If you need to save simple, unstructured key-value data in your multiplatform apps, I hope you'll consider using it. A lot of you already are!
russhwolf / multiplatform-settings
A Kotlin Multiplatform library for saving simple key-value data
Multiplatform Settings
This is a Kotlin library for Multiplatform apps, so that common code can persist key-value data.
A Korean translation of this readme is available separately, maintained by @wooram-yang
Table of contents
Usage
The Settings
interface has implementations on the Android, iOS, macOS, watchOS, tvOS, JS, WasmJS, JVM, and Windows
platforms.
Implementation Summary
The following table shows the names of implementing classes and what platforms they're available on.
Class | Backing API | Platforms |
---|---|---|
KeychainSettings 2
|
Apple Keychain | iOS, macOS, watchOS, tvOS |
NSUserDefaultsSettings 1
|
User Defaults | iOS, macOS, watchOS, tvOS |
PreferencesSettings 1
|
java.util.prefs.Preferences |
JVM |
PropertiesSettings |
java.util.Properties |
JVM |
SharedPreferencesSettings 1
|
android.content.SharedPreferences |
Android |
StorageSettings |
Web Storage (localStorage) | JS, WasmJS |
RegistrySettings 2
|
Windows Registry | MingwX64 |
MapSettings 1,3
|
Some History
Multiplatform Settings was one of the first Kotlin Multiplatform libraries ever released, with the first version published on May 28, 2018. I called that first version 0.1-alpha, though I would later drop the alpha from the versioning scheme as it's somewhat redundant with 0.x. At the time I always imagined that I would call the library 0.x until the overall Multiplatform tooling was labelled as stable, but that's been a longer process than I originally expected. Now that Kotlin Multiplatform Mobile is officially in Beta and we're seeing a big uptick in interest and usage in the community, this seems like a good moment for it.
What's next?
As I detailed in my last post, there are a couple things still marked as experimental in this first stable release, and without committing to any specific timeline, I'd like to stabilize them in the near future. If you're a user of KeychainSettings
, RegistrySettings
, multiplatform-settings-coroutines
, or multiplatform-settings-serialization
, I'm very interested in hearing your feedback on how well they're working for you. Bug reports or issues you've had using these APIs are helpful for improving them, but so are reports that you've used them and they've worked well, because that's what tells me that they're ready for wider use.
What about DataStore?
One thing that's new since I started planning this 1.0 release is that Google announced a preview multiplatform version of the DataStore library. This has a very similar use-case to Multiplatform Settings, so which should you use?
One difference between these two libraries is, Multiplatform Settings focuses on interop with existing platform APIs, while DataStore is a brand new implementation. This means that if you have existing platform code using SharedPreferences, UserDefaults, web Storage, or any of the other platform APIs that Multiplatform Settings supports, you can continue to use that code and it will share its source of truth with your common code using Multiplatform Settings.
If that interop is not a concern for you, then DataStore can also be a great choice. And with the multiplatform-settings-coroutines
and multiplatform-settings-datastore
modules, you can wrap DataStore in the Multiplatform Settings API, if you want use DataStore in some places and Multiplatform Settings in others. These modules are currently only available on Android and JVM, but I intend to release them on other platforms once the multiplatform DataStore becomes more stable.
Thanks for reading
It's an exciting time to be building things with Kotlin Multiplatform! I hope you find this first stable release of Multiplatform Settings helpful for your KMP projects. Let me know in the issues or discussions if you encounter any problems or have any other feedback.
Top comments (0)