0Pricing
Kotlin Multiplatform Academy · درس

غيّر مرة واحدة وشاهد النتيجة في التطبيقين

تعديل المنطق المشترك ومراقبة تحديث المنصتين

غيّر مرة واحدة وشاهد النتيجة في التطبيقين درس مجاني في Kotlin Multiplatform Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Kotlin Multiplatform Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Kotlin Multiplatform Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

The Real Payoff

Now comes the magic of KMP: edit the shared function once and both apps change together. No copy-paste, no drift.

Tweak the Greeting

Open greet in commonMain and change the wording. This is the only place you touch, even though two apps depend on it.

fun greet(name: String): String {
    return "Welcome, $name!"
}

Rebuild Android

Run the Android app again. Because it links the shared module, it instantly shows the new Welcome text with zero extra edits.

Rebuild iOS

Rebuild the iOS app and the same new line appears. The shared framework was recompiled from the one source you changed.

Add Logic, Not Just Text

Change behavior too, like trimming spaces. Both platforms gain the fix at once, because the logic truly lives in one place.

fun greet(name: String): String {
    return "Welcome, " + name.trim() + "!"
}

One Bug, One Fix

If greet had a bug, you fix it once and both apps are healed. That is the consistency KMP is built to give you.

Why Builds Are Needed

Each platform compiles the shared code into its own artifact. So after an edit, both apps need a fresh build to pick it up.

Tests Guard the Logic

Write one test for greet in commonTest and it protects every platform. A single safety net covers all your apps.

Less Code to Maintain

Sharing logic shrinks your surface area. Fewer lines, fewer places for bugs, and behavior that can never disagree across apps.

Keep UI Native

The text changed everywhere, but each app still styles it with its own UI. You share the brain and keep platform-native looks. 💡

You Did It End to End

You wrote shared code, called it from both apps, and proved a single edit updates them together. That is the whole KMP loop. 🎉

Quick Check

What happens after you edit shared logic?

Recap

One edit in commonMain flowed to both apps after a rebuild. Share the logic, test it once, and keep each UI native. 🎉

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

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

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

ماذا ستتعلم في «غيّر مرة واحدة وشاهد النتيجة في التطبيقين»؟

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

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

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

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

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

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

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

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

  1. دالة ترحيب في commonMain
  2. استدعاء التعليمات البرمجية المشتركة من تطبيق Android
  3. استدعاء التعليمات البرمجية المشتركة من تطبيق iOS
  4. غيّر مرة واحدة وشاهد النتيجة في التطبيقين
← العودة إلى Kotlin Multiplatform Academy