0Pricing
Kotlin Multiplatform Academy · レッスン

shared ModuleとApp Modules

共有ライブラリをAndroidアプリとiOSアプリに組み込む方法を学びます

「shared ModuleとApp Modules」はCoddyKit上の無料Kotlin Multiplatform Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはKotlin Multiplatform Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Two Apps, One Brain

A KMP project has two app modules plus one shared module. The shared module is the brain both apps borrow from. 🧠

What the shared Module Is

The shared module is a Kotlin library, not an app. It holds logic you want to write once and reuse on Android and iOS.

The androidApp Module

The androidApp module is a normal Android app. It depends on shared and adds Android-only UI and resources on top.

The iosApp Module

The iosApp is an Xcode project. It links a framework built from shared and presents the native iOS screens.

Dependency Flows One Way

The apps depend on shared, never the reverse. Shared code stays portable because it knows nothing about either app.

How Android Plugs In

Android wires shared in with a simple Gradle dependency. Once added, every shared class is importable in Kotlin.

dependencies {
    implementation(project(":shared"))
}

How iOS Plugs In

iOS does not use Gradle directly. Instead it imports a generated framework and calls your Kotlin from Swift.

import shared

let greeting = Greeting().greet()

Why Split It This Way

Splitting apps from shared keeps a clear boundary: business logic in one place, platform UI in its own home.

What Goes Where

Rule of thumb: logic, models and rules go in shared; screens, navigation and platform widgets stay in each app.

The shared Module Has Its Own Build

The shared module owns a build.gradle.kts that lists its targets. Each app also keeps its own build file.

Many Apps, Same Module

The same shared module can also feed a desktop or web app later. One library, many front ends. 🚀

Quick Check

Let us check how the modules relate.

Recap

You met the trio: one shared brain plus an androidApp and an iosApp that depend on it. Logic in shared, UI in the apps.

よくある質問

「shared ModuleとApp Modules」レッスンは無料ですか?

はい。「shared ModuleとApp Modules」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Kotlin Multiplatform Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Kotlin Multiplatform Academyコースには全4レッスンが含まれています。

「shared ModuleとApp Modules」で何を学びますか?

共有ライブラリをAndroidアプリとiOSアプリに組み込む方法を学びます ブラウザで直接実行するハンズオンコードでKotlin Multiplatform Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Kotlin Multiplatform Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのKotlin Multiplatform Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「shared ModuleとApp Modules」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このKotlin Multiplatform Academyレッスンでコードを書いて実行できますか?

はい。すべてのKotlin Multiplatform Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. shared ModuleとApp Modules
  2. commonMain、androidMain、iosMain
  3. 共有build.gradle.ktsを読む
  4. テストはどこにあるか:commonTestと仲間たち
← Kotlin Multiplatform Academyに戻る