0Pricing
Kotlin Multiplatform Academy · บทเรียน

เปิดและเรียกใช้แอป iOS ใน Xcode

เปิดแอป iOS ที่ลิงก์เฟรมเวิร์ก shared ของคุณ

เปิดและเรียกใช้แอป iOS ใน Xcode เป็นบทเรียน Kotlin Multiplatform Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Kotlin Multiplatform Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Kotlin Multiplatform Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Now the iOS Side

Android worked, so let's light up iOS. The iOS app lives in its own folder and you build it with Xcode, not Android Studio. 🍎

Open the Xcode Project

Inside the iosApp folder you'll find a project or workspace file. Double-click it to open the iOS app in Xcode.

open iosApp/iosApp.xcodeproj

Workspace vs Project File

If your setup uses CocoaPods, always open the .xcworkspace file. The plain .xcodeproj will miss the pod dependencies.

Pick a Scheme and Simulator

At the top of Xcode, choose the iosApp scheme and a simulator like iPhone 15 from the device dropdown.

The Shared Framework Link

The iOS app does not consume Kotlin source directly. It links a precompiled framework that Gradle produces from your shared module.

A Build Phase Runs Gradle

A custom build phase in Xcode calls Gradle first. That step compiles the shared framework before Swift code is even touched.

./gradlew :shared:embedAndSignAppleFrameworkForXcode

Press Run in Xcode

Click the Run triangle. Xcode triggers Gradle, builds the framework, compiles Swift, and boots the simulator with your app.

Call Shared Code from Swift

Your Swift screen imports the framework and calls the shared API by name. The same logic that ran on Android now runs on iOS.

import shared
let text = Greeting().greet()

First Build Is the Slow One

The very first iOS build compiles the whole framework, so be patient. Later runs reuse cached output and feel much faster. ⏳

Read Errors in the Issue Navigator

When something fails, open the Issue Navigator. Gradle errors and Swift errors both surface here with a jump-to-line link.

Same Logic, Two Apps

Seeing your shared greeting in the iOS simulator closes the loop. One Kotlin codebase is now powering both native apps.

Quick Check

Let's confirm how iOS consumes your shared Kotlin.

Recap

You opened the iosApp in Xcode, picked a simulator, and pressed Run. A build phase ran Gradle to make the framework, then Swift called your shared code live. 🎉

คำถามที่พบบ่อย

บทเรียน “เปิดและเรียกใช้แอป iOS ใน Xcode” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “เปิดและเรียกใช้แอป iOS ใน Xcode” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Kotlin Multiplatform Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Kotlin Multiplatform Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เปิดและเรียกใช้แอป iOS ใน Xcode”

เปิดแอป iOS ที่ลิงก์เฟรมเวิร์ก shared ของคุณ คุณปฏิบัติ Kotlin Multiplatform Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Kotlin Multiplatform Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Kotlin Multiplatform Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน

บทเรียน “เปิดและเรียกใช้แอป iOS ใน Xcode” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Kotlin Multiplatform Academy นี้ได้ไหม

ได้ บทเรียน Kotlin Multiplatform Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เรียกใช้แอป Android จาก Studio
  2. เปิดและเรียกใช้แอป iOS ใน Xcode
  3. วิธีสร้างเฟรมเวิร์ก iOS
  4. แก้ไขปัญหาโค้ด shared ไม่พบ
← กลับไปที่ Kotlin Multiplatform Academy