Skip to content

Commit

Permalink
Update Kotlin sdk version constant and add info about k2 compilation …
Browse files Browse the repository at this point in the history
…support
  • Loading branch information
cbullinger committed May 7, 2024
1 parent ec69835 commit 9fee841
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 58 deletions.
4 changes: 2 additions & 2 deletions snooty.toml
Expand Up @@ -83,11 +83,11 @@ atlas = "Atlas"
admin-api-page = "/admin/api/v3/#"
base-url = "https://www.mongodb.com/docs/realm"
cpp-prefix = "https://www.mongodb.com/docs/realm-sdks/cpp/latest"
kotlin-sdk-version = "1.11.0"
kotlin-sdk-version = "1.16.0"
kotlinx-coroutines-version = "1.7.0"
kotlin-sync-prefix = "https://www.mongodb.com/docs/realm-sdks/kotlin/latest/library-sync/"
kotlin-local-prefix = "https://www.mongodb.com/docs/realm-sdks/kotlin/latest/library-base/"
java-sdk-version = "10.11.1"
java-sdk-version = "10.18.0"
max-graphql-resolvers = "ten"
max-graphql-relationship-depth = "five"
name-char-limit = "57"
Expand Down
141 changes: 85 additions & 56 deletions source/sdk/kotlin/install.txt
Expand Up @@ -10,9 +10,16 @@ Install the Kotlin SDK
:depth: 2
:class: singlecol

.. meta::
:description: Learn how to install the Atlas Device SDK for Kotlin in your Android and Kotlin Multiplatform (KMP) projects.
:keywords: code example

The Kotlin SDK supports two platforms, each with its own installation
method:
.. facet::
:name: genre
:values: tutorial

The Atlas Device SDK for Kotlin supports the following platforms. Each has its own installation
method and requirements:

- :ref:`Android <kotlin-install-android>`
- :ref:`Kotlin Multiplatform (KMP) <kotlin-install-kotlin-multiplatform>`
Expand All @@ -28,19 +35,21 @@ meets the following prerequisites:
- Kotlin Plugin for Android Studio, version 1.6.10 or higher.
- An Android Virtual Device (AVD) using a supported CPU architecture.

For a list of supported target environments, refer to the :ref:`kotlin-supported-environments` section on this page.

Additionally, Kotlin Multiplatform (KMP) for mobile projects require the following:

- `Kotlin Multiplatform Mobile (KMM) Plugin
<https://kotlinlang.org/docs/mobile/kmm-plugin-releases.html#release-details>`__
for Android Studio, version 0.3.1 or higher.
- A Kotlin Multiplatform (KMP) App created using the "Kotlin Multiplatform App"
template in Android Studio. Follow the instructions in the
`Kotlin Multiplatform documentation
- A Kotlin Multiplatform (KMP) App created using the "Kotlin Multiplatform App"
template in Android Studio. Follow the instructions in the
`Kotlin Multiplatform documentation
<https://kotlinlang.org/docs/mobile/create-first-app.html>`__.

For more details on setting up your KMP environment, refer to the `official Kotlin
Kotlin Multiplatform for mobile documentation
<https://kotlinlang.org/docs/multiplatform-mobile-setup.html>`__. To verify your
Kotlin Multiplatform for mobile
<https://kotlinlang.org/docs/multiplatform-mobile-setup.html>`__ documentation. To verify your
environment setup, follow Kotlin's `guide to checking your
environment
<https://kotlinlang.org/docs/multiplatform-mobile-setup.html#check-your-environment>`__.
Expand All @@ -50,8 +59,8 @@ environment
The Kotlin Multiplatform (KMP) ecosystem frequently changes. If you experience
any issues installing the SDK, check your Kotlin Plugin version, since
outdated plugins can lead to difficult to debug errors. To see which
versions of the Kotlin Plugin are compatible with the SDK, see the
`realm-kotlin changelog <https://github.com/realm/realm-kotlin/blob/master/CHANGELOG.md>`__.
versions of the Kotlin Plugin are compatible with the SDK, refer to the
`SDK changelog <https://github.com/realm/realm-kotlin/blob/master/CHANGELOG.md>`__.

.. _kotlin-install-kotlin-multiplatform:
.. _kotlin-install-android:
Expand All @@ -72,32 +81,32 @@ Installation

.. tab:: Android
:tabid: android
Add :file:`io.realm.kotlin`, specifying the library version and
:file:`apply false`, to the list of plugins in your project-level Gradle

Add :file:`io.realm.kotlin`, specifying the library version and
:file:`apply false`, to the list of plugins in your project-level Gradle
build file, typically found at :file:`<project>/build.gradle`:

.. code-block:: kotlin
:caption: Global build.gradle

plugins {
id 'io.realm.kotlin' version '{+kotlin-sdk-version+}' apply false
}

Add the following to your app-level Gradle build file, typically
found at :file:`<project>/app/build.gradle`:

- Add :file:`io.realm.kotlin` to the list of plugins.
- Add the following to the list of dependencies:

- Add :file:`io.realm.kotlin:library-base` to the dependencies block.
- If using Device Sync in your application, add :file:`io.realm.kotlin:library-sync` to the dependencies block.

- To use coroutines with the SDK, add :file:`org.jetbrains.kotlinx:kotlinx-coroutines-core` to the list of dependencies.

.. code-block:: kotlin
:caption: Module build.gradle
:emphasize-lines: 4, 12, 13, 14
:emphasize-lines: 4, 12-18

plugins {
id 'com.android.application'
Expand All @@ -110,61 +119,65 @@ Installation
}

dependencies {
implementation 'io.realm.kotlin:library-base:{+kotlin-sdk-version+}'
implementation 'io.realm.kotlin:library-sync:{+kotlin-sdk-version+}'// If using Device Sync
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:{+kotlinx-coroutines-version+}' // If using coroutines with the SDK
implementation 'io.realm.kotlin:library-base:{+kotlin-sdk-version+}'

// If using Device Sync
implementation 'io.realm.kotlin:library-sync:{+kotlin-sdk-version+}'

// If using coroutines with the SDK
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:{+kotlinx-coroutines-version+}'
}

.. tab:: Kotlin Multiplatform (KMP)
:tabid: kmp

Add the following to your app-level Gradle build file, typically
found at :file:`<project>/app/build.gradle`:
1. Add the following to your app-level Gradle build file, typically found at :file:`<project>/app/build.gradle`:

- Add :file:`io.realm.kotlin` to the list of plugins.
- Add the following to the list of dependencies:

- Add :file:`io.realm.kotlin:library-base` to the dependencies block.
- If using Device Sync in your application, add :file:`io.realm.kotlin:library-sync` to the dependencies block.
- Add :file:`io.realm.kotlin` to the list of plugins.
- Add the following to the list of dependencies:

- To use coroutines with the SDK, add :file:`org.jetbrains.kotlinx:kotlinx-coroutines-core` to the list of dependencies.
- Add :file:`io.realm.kotlin:library-base` to the dependencies block.
- If using Device Sync in your application, add :file:`io.realm.kotlin:library-sync` to the dependencies block.

.. code-block:: kotlin
:caption: Module build.gradle
:emphasize-lines: 5, 18, 19, 20
- To use coroutines with the SDK, add :file:`org.jetbrains.kotlinx:kotlinx-coroutines-core` to the list of dependencies.

plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
id("io.realm.kotlin") version "{+kotlin-sdk-version+}"
}
.. code-block:: kotlin
:caption: App build.gradle
:emphasize-lines: 5, 18-24

plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
id("io.realm.kotlin") version "{+kotlin-sdk-version+}"
}

version = "1.0"

kotlin {
android()
iosX64()
iosArm64()

version = "1.0"
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.realm.kotlin:library-base:{+kotlin-sdk-version+}")

kotlin {
android()
iosX64()
iosArm64()
// If using Device Sync
implementation("io.realm.kotlin:library-sync:{+kotlin-sdk-version+}")

sourceSets {
val commonMain by getting {
dependencies {
implementation("io.realm.kotlin:library-base:{+kotlin-sdk-version+}")
implementation("io.realm.kotlin:library-sync:{+kotlin-sdk-version+}") // If using Device Sync
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:{+kotlinx-coroutines-version+}") // If using coroutines with the SDK
// If using coroutines with the SDK
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:{+kotlinx-coroutines-version+}")
}
}
}
}
}

.. note:: Android Module Dependencies

If you use any part of the SDK inside the Android module, add the
SDK's compile-time dependency to your Android module :file:`build.gradle.kts`:
2. If you use any part of the SDK inside the Android module, add the following compile-time dependencies to your module-level Gradle build file, typically found at :file:`<project>/module/build.gradle`:

.. code-block:: kotlin
:copyable: false
:caption: Android Module build.gradle

dependencies {
compileOnly("io.realm.kotlin:library-base:{+kotlin-sdk-version+}")
Expand All @@ -175,19 +188,21 @@ Installation
compileOnly("io.realm.kotlin:library-sync:{+kotlin-sdk-version+}")
}

.. step:: Sync Gradle Files
.. step:: Sync Gradle Files

After updating the Gradle configuration,
resolve the dependencies by clicking :guilabel:`File` >
:guilabel:`Sync Project with Gradle Files` in the Android Studio menu bar.
You can now use the Kotlin SDK in your application.

.. _kotlin-supported-environments:

Supported Target Environments
-----------------------------

Kotlin Multiplatform (KMP) supports a `wide range of application environments
<https://kotlinlang.org/docs/multiplatform-dsl-reference.html#targets>`__.
Kotlin Multiplatform (KMP) supports a wide range of application environments
Refer also to Kotlin's `Multiplatform Gradle DSL reference: Targets
<https://kotlinlang.org/docs/multiplatform-dsl-reference.html#targets>`__ documentation.

Supported Environments
~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -239,3 +254,17 @@ The Kotlin SDK does *not* support the following environments:
- :file:`watchosSimulatorArm64`
- :file:`watchosX86`
- :file:`watchosX64`

Support for Experimental K2 Compiler
------------------------------------

.. versionadded:: 1.13.0

The Kotlin SDK version 1.13.0 and later supports the experimental K2 compiler
with Kotlin version 1.9.0.

To use the K2 compiler in your project, add the following to your project-level
Gradle properties file: ``kotlin.experimental.tryK2=true``.

For more information on the K2 compiler, including minimum requirements, refer to Kotlin's `Try the K2 compiler in your project
<https://kotlinlang.org/docs/whatsnew19.html#try-the-k2-compiler-in-your-project>`__.

0 comments on commit 9fee841

Please sign in to comment.