0Pricing
Kotlin Multiplatform Academy · درس

الوحدة المشتركة مقابل وحدات التطبيق

كيفية اتصال المكتبة المشتركة بتطبيقَي Android وiOS

الوحدة المشتركة مقابل وحدات التطبيق درس مجاني في Kotlin Multiplatform Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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.

الأسئلة الشائعة

هل درس «الوحدة المشتركة مقابل وحدات التطبيق» مجاني؟

نعم — نص درس «الوحدة المشتركة مقابل وحدات التطبيق» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Kotlin Multiplatform Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Kotlin Multiplatform Academy 4 دروس في المجموع.

ماذا ستتعلم في «الوحدة المشتركة مقابل وحدات التطبيق»؟

كيفية اتصال المكتبة المشتركة بتطبيقَي Android وiOS تتمرن على Kotlin Multiplatform Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Kotlin Multiplatform Academy؟

لا تُشترط خبرة سابقة. Kotlin Multiplatform Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «الوحدة المشتركة مقابل وحدات التطبيق»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Kotlin Multiplatform Academy هذا؟

نعم. كل درس في Kotlin Multiplatform Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. الوحدة المشتركة مقابل وحدات التطبيق
  2. commonMain وandroidMain وiosMain
  3. قراءة build.gradle.kts المشترك
  4. أين توجد الاختبارات: commonTest وما شابهها
← العودة إلى Kotlin Multiplatform Academy