0Pricing
Kotlin Multiplatform Academy · レッスン

iOS向けXCFrameworkを出荷する

Swift利用者に配布できるフレームワークをビルドします

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

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

iOS Needs a Framework

Swift consumers cannot use a Maven JAR. They expect an Apple-native bundle, and the modern format for that is the XCFramework. 🍎

What an XCFramework Is

An XCFramework packages compiled binaries for several architectures in one bundle, so it works on devices and simulators alike.

Why Not a Plain Framework

An old fat framework mixed device and simulator slices and broke on Apple Silicon. The XCFramework keeps each slice separate and clean.

Declare Your iOS Targets

List the iOS targets you support in the kotlin block. Each one becomes a slice inside the final XCFramework bundle.

kotlin {
    iosArm64()
    iosSimulatorArm64()
}

Name the Framework

Give your framework a clear baseName. Swift code imports it by exactly this name, so pick something the iOS team will recognize.

binaries.framework {
    baseName = "Shared"
}

Build the XCFramework

The Kotlin plugin adds an assembleXCFramework task that compiles every iOS target and bundles them together for you.

./gradlew :shared:assembleSharedXCFramework

Static vs Dynamic

A static framework links into the app at build time, while a dynamic one loads at launch. Static is the common default for KMP libraries.

Find the Output

The finished bundle lands in your build folder as Shared.xcframework. That single file is what iOS developers will integrate.

Add It in Xcode

iOS devs drag the bundle into their project and add it under Frameworks. From there, Swift can import and call your shared API.

import Shared
let greeting = Greeting().greet()

Distribute as a Zip

For sharing, zip the bundle and host it somewhere downloadable. A checksum lets consumers verify the file arrived intact.

Rebuild on Every Change

The XCFramework is a snapshot of your code. After shared changes, reassemble it so iOS gets the latest logic instead of stale binaries.

Quick Check

Let's check your iOS packaging knowledge.

Recap

Declare your iOS targets, name the framework, run assembleXCFramework, then hand the bundle to Xcode for Swift to import. 🎉

よくある質問

「iOS向けXCFrameworkを出荷する」レッスンは無料ですか?

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

「iOS向けXCFrameworkを出荷する」で何を学びますか?

Swift利用者に配布できるフレームワークをビルドします ブラウザで直接実行するハンズオンコードでKotlin Multiplatform Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「iOS向けXCFrameworkを出荷する」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. KMP向けにmaven-publishを設定する
  2. iOS向けXCFrameworkを出荷する
  3. バージョン管理とAPIの安定性
  4. Maven CentralとSPMにリリースする
← Kotlin Multiplatform Academyに戻る